Average Error: 37.0 → 13.8
Time: 1.4m
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le -3.807904579939038 \cdot 10^{-18}:\\ \;\;\;\;\frac{\left(\left(\tan \varepsilon + \tan x\right) \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)\right) \cdot \cos x - \left(1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)\right) \cdot \sin x}{\left(1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)\right) \cdot \cos x}\\ \mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le 3.5032388856304835 \cdot 10^{-31}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \left(\sqrt[3]{\tan x \cdot \tan \varepsilon} \cdot \sqrt[3]{\tan x \cdot \tan \varepsilon}\right) \cdot \sqrt[3]{\tan x \cdot \tan \varepsilon}} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.0
Target15.2
Herbie13.8
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < -3.807904579939038e-18

    1. Initial program 35.8

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

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

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)} - \tan x\]
    7. Applied simplify9.5

      \[\leadsto \color{blue}{\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
    8. Using strategy rm
    9. Applied tan-quot9.6

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
    10. Applied associate-*l/9.6

      \[\leadsto \color{blue}{\frac{\left(\tan \varepsilon + \tan x\right) \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)}} - \frac{\sin x}{\cos x}\]
    11. Applied frac-sub9.6

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

    if -3.807904579939038e-18 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < 3.5032388856304835e-31

    1. Initial program 39.8

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Taylor expanded around 0 15.7

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

    if 3.5032388856304835e-31 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x)))

    1. Initial program 35.6

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\left(\sqrt[3]{\tan x \cdot \tan \varepsilon} \cdot \sqrt[3]{\tan x \cdot \tan \varepsilon}\right) \cdot \sqrt[3]{\tan x \cdot \tan \varepsilon}}} - \tan x\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed 2018207 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

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

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