Average Error: 37.3 → 8.3
Time: 41.9s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -3.9441692661555314 \cdot 10^{-11}:\\ \;\;\;\;\frac{\left(\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left({1}^{3} + {\left(\tan x \cdot \tan \varepsilon\right)}^{3}\right)\right) \cdot \cos x - \left(1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) - 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) \cdot \sin x}{\cos x + \left(\tan x \cdot \tan \varepsilon - 1\right) \cdot \left(\cos x \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)}\\ \mathbf{if}\;\varepsilon \le 6.004702107311532 \cdot 10^{-43}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original37.3
Comparison28.0
Herbie8.3
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -3.9441692661555314e-11

    1. Initial program 29.3

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

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

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

      \[\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 simplify 0.6

      \[\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-quot 0.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 flip3-+ 0.6

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \color{blue}{\frac{{1}^{3} + {\left(\tan x \cdot \tan \varepsilon\right)}^{3}}{1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) - 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)}} - \frac{\sin x}{\cos x}\]
    11. Applied associate-*r/ 0.6

      \[\leadsto \color{blue}{\frac{\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left({1}^{3} + {\left(\tan x \cdot \tan \varepsilon\right)}^{3}\right)}{1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) - 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)}} - \frac{\sin x}{\cos x}\]
    12. Applied frac-sub 0.7

      \[\leadsto \color{blue}{\frac{\left(\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left({1}^{3} + {\left(\tan x \cdot \tan \varepsilon\right)}^{3}\right)\right) \cdot \cos x - \left(1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) - 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) \cdot \sin x}{\left(1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) - 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right) \cdot \cos x}}\]
    13. Applied simplify 0.7

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

    if -3.9441692661555314e-11 < eps < 6.004702107311532e-43

    1. Initial program 46.0

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

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

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

    if 6.004702107311532e-43 < eps

    1. Initial program 30.7

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

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

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

      \[\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}}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 41.9s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1067901057 3396600083 3715501224 3126139233 3908045574 1593683916)'
(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)))