Average Error: 36.6 → 15.1
Time: 39.9s
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.0632206414980774 \cdot 10^{-82}:\\ \;\;\;\;\frac{\cos x \cdot \left(\tan \varepsilon + \tan x\right) - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \mathbf{elif}\;\varepsilon \le 1.496652297597833 \cdot 10^{-63}:\\ \;\;\;\;\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}}{\tan \varepsilon + \tan x}} - \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.6
Target15.2
Herbie15.1
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -1.0632206414980774e-82

    1. Initial program 30.7

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

      \[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
    4. Applied tan-sum6.7

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
    5. Applied frac-sub6.7

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

    if -1.0632206414980774e-82 < eps < 1.496652297597833e-63

    1. Initial program 47.7

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Taylor expanded around 0 30.4

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

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

    if 1.496652297597833e-63 < eps

    1. Initial program 29.4

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

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

      \[\leadsto \frac{\tan x + \color{blue}{1 \cdot \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied *-un-lft-identity5.1

      \[\leadsto \frac{\color{blue}{1 \cdot \tan x} + 1 \cdot \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    7. Applied distribute-lft-out5.1

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x\]
    9. Using strategy rm
    10. Applied tan-quot5.2

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

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}}}{\tan x + \tan \varepsilon}} - \tan x\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \le -1.0632206414980774 \cdot 10^{-82}:\\ \;\;\;\;\frac{\cos x \cdot \left(\tan \varepsilon + \tan x\right) - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \mathbf{elif}\;\varepsilon \le 1.496652297597833 \cdot 10^{-63}:\\ \;\;\;\;\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 - \frac{\sin \varepsilon \cdot \tan x}{\cos \varepsilon}}{\tan \varepsilon + \tan x}} - \tan x\\ \end{array}\]

Runtime

Time bar (total: 39.9s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes21.615.114.17.587%
herbie shell --seed 2018351 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

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

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