Average Error: 36.4 → 11.2
Time: 2.6m
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -2.4610266585566768 \cdot 10^{-113}:\\ \;\;\;\;\frac{{\left(\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}\right)}^2 - {\left(\tan x\right)}^2}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\ \mathbf{if}\;\varepsilon \le 3.1547769921923584 \cdot 10^{-35}:\\ \;\;\;\;{x}^2 \cdot {\varepsilon}^3 + \left(\varepsilon + {x}^3 \cdot {\varepsilon}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{{\left(\tan \varepsilon \cdot \sin x\right)}^3}{{\left(\cos 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

Original36.4
Comparison24.9
Herbie11.2
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -2.4610266585566768e-113

    1. Initial program 30.8

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

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

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

    if -2.4610266585566768e-113 < eps < 3.1547769921923584e-35

    1. Initial program 47.1

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

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

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

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

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

    if 3.1547769921923584e-35 < eps

    1. Initial program 29.3

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

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

      \[\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/ 2.6

      \[\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 2.6

      \[\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 tan-quot 2.6

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - {\left(\tan \varepsilon \cdot \color{blue}{\frac{\sin x}{\cos 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\]
    10. Applied associate-*r/ 2.6

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - {\color{blue}{\left(\frac{\tan \varepsilon \cdot \sin x}{\cos 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\]
    11. Applied cube-div 2.6

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \color{blue}{\frac{{\left(\tan \varepsilon \cdot \sin x\right)}^3}{{\left(\cos 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\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 2.6m) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(772101555 1905824529 294602591 2478279198 2123125427 4197813737)'
(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)))