Average Error: 37.0 → 9.7
Time: 30.8s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -2.3749642250710625 \cdot 10^{-44}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - {\left(\tan \varepsilon\right)}^3 \cdot {\left(\tan x\right)}^3} \cdot \left({1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x\\ \mathbf{if}\;\varepsilon \le 1.8344586189103676 \cdot 10^{-35}:\\ \;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - {\left(\tan \varepsilon\right)}^3 \cdot {\left(\tan x\right)}^3} \cdot \left({1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original37.0
Comparison26.5
Herbie9.7
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 2 regimes.
  2. if eps < -2.3749642250710625e-44 or 1.8344586189103676e-35 < eps

    1. Initial program 30.4

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Using strategy rm
    3. Applied tan-sum 3.3

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied flip3-- 3.4

      \[\leadsto \frac{\tan x + \tan \varepsilon}{\color{blue}{\frac{{1}^{3} - {\left(\tan x \cdot \tan \varepsilon\right)}^{3}}{{1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)}}} - \tan x\]
    6. Applied associate-/r/ 3.4

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{{1}^{3} - {\left(\tan x \cdot \tan \varepsilon\right)}^{3}} \cdot \left({1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right)} - \tan x\]
    7. Applied simplify 3.4

      \[\leadsto \color{blue}{\frac{\tan \varepsilon + \tan x}{1 - {\left(\tan \varepsilon \cdot \tan x\right)}^3}} \cdot \left({1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x\]
    8. Using strategy rm
    9. Applied cube-prod 3.4

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \color{blue}{{\left(\tan \varepsilon\right)}^3 \cdot {\left(\tan x\right)}^3}} \cdot \left({1}^2 + \left({\left(\tan x \cdot \tan \varepsilon\right)}^2 + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) - \tan x\]

    if -2.3749642250710625e-44 < eps < 1.8344586189103676e-35

    1. Initial program 45.8

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Applied taylor 18.1

      \[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
    3. Taylor expanded around 0 18.1

      \[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
    4. Applied simplify 18.1

      \[\leadsto \color{blue}{\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 30.8s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1065033997 2389885643 4100569014 2620012693 26800780 3144211646)'
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"
  :herbie-expected 28

  :target
  (/ (sin eps) (* (cos x) (cos (+ x eps))))

  (- (tan (+ x eps)) (tan x)))