Average Error: 36.9 → 14.7
Time: 44.3s
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -4.219213708454689 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x \cdot \tan x}{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\ \mathbf{elif}\;\varepsilon \le 1.3180018927867864 \cdot 10^{-23}:\\ \;\;\;\;x \cdot {\varepsilon}^{2} + \left({\varepsilon}^{3} \cdot {x}^{2} + \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{\log \left(e^{\sin \varepsilon \cdot \tan x}\right)}{\cos \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

Original36.9
Target14.8
Herbie14.7
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -4.219213708454689e-16

    1. Initial program 30.0

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

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

      \[\leadsto \color{blue}{\frac{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x \cdot \tan x}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} + \tan x}}\]

    if -4.219213708454689e-16 < eps < 1.3180018927867864e-23

    1. Initial program 45.5

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

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

    if 1.3180018927867864e-23 < eps

    1. Initial program 28.5

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
    6. Applied associate-*r/1.4

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
    7. Using strategy rm
    8. Applied add-log-exp1.5

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \frac{\color{blue}{\log \left(e^{\tan x \cdot \sin \varepsilon}\right)}}{\cos \varepsilon}} - \tan x\]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \le -4.219213708454689 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x \cdot \tan x}{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\ \mathbf{elif}\;\varepsilon \le 1.3180018927867864 \cdot 10^{-23}:\\ \;\;\;\;x \cdot {\varepsilon}^{2} + \left({\varepsilon}^{3} \cdot {x}^{2} + \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{\log \left(e^{\sin \varepsilon \cdot \tan x}\right)}{\cos \varepsilon}} - \tan x\\ \end{array}\]

Runtime

Time bar (total: 44.3s)Debug logProfile

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

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

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