Average Error: 36.6 → 15.4
Time: 42.6s
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -5.281593363047552 \cdot 10^{-78}:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon} + \frac{\sin x}{\cos x}}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\ \mathbf{elif}\;\varepsilon \le 4.606203760411138 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \left(\varepsilon \cdot \left(\varepsilon + x\right)\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \tan \varepsilon \cdot \tan x\right) \cdot \frac{\tan x + \tan \varepsilon}{1 - \frac{\left(\tan \varepsilon \cdot \tan x\right) \cdot \sqrt[3]{\left(\left(\sin \varepsilon \cdot \sin x\right) \cdot \left(\sin \varepsilon \cdot \sin x\right)\right) \cdot \left(\sin \varepsilon \cdot \sin x\right)}}{\cos \varepsilon \cdot \cos x}} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.6
Target15.2
Herbie15.4
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -5.281593363047552e-78

    1. Initial program 30.5

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

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

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

    if -5.281593363047552e-78 < eps < 4.606203760411138e-25

    1. Initial program 45.8

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

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

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

      \[\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. Taylor expanded around 0 31.3

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

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

    if 4.606203760411138e-25 < eps

    1. Initial program 29.7

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied flip--1.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/1.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. Using strategy rm
    8. Applied tan-quot1.6

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

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \color{blue}{\frac{\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\sin x \cdot \sin \varepsilon\right)}{\cos x \cdot \cos \varepsilon}}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
    12. Using strategy rm
    13. Applied add-cbrt-cube1.6

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \frac{\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\sin x \cdot \color{blue}{\sqrt[3]{\left(\sin \varepsilon \cdot \sin \varepsilon\right) \cdot \sin \varepsilon}}\right)}{\cos x \cdot \cos \varepsilon}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
    14. Applied add-cbrt-cube1.7

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \frac{\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\color{blue}{\sqrt[3]{\left(\sin x \cdot \sin x\right) \cdot \sin x}} \cdot \sqrt[3]{\left(\sin \varepsilon \cdot \sin \varepsilon\right) \cdot \sin \varepsilon}\right)}{\cos x \cdot \cos \varepsilon}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
    15. Applied cbrt-unprod1.6

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \frac{\left(\tan x \cdot \tan \varepsilon\right) \cdot \color{blue}{\sqrt[3]{\left(\left(\sin x \cdot \sin x\right) \cdot \sin x\right) \cdot \left(\left(\sin \varepsilon \cdot \sin \varepsilon\right) \cdot \sin \varepsilon\right)}}}{\cos x \cdot \cos \varepsilon}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
    16. Simplified1.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \le -5.281593363047552 \cdot 10^{-78}:\\ \;\;\;\;\frac{\frac{\sin \varepsilon}{\cos \varepsilon} + \frac{\sin x}{\cos x}}{1 - \tan \varepsilon \cdot \tan x} - \tan x\\ \mathbf{elif}\;\varepsilon \le 4.606203760411138 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \left(\varepsilon \cdot \left(\varepsilon + x\right)\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \tan \varepsilon \cdot \tan x\right) \cdot \frac{\tan x + \tan \varepsilon}{1 - \frac{\left(\tan \varepsilon \cdot \tan x\right) \cdot \sqrt[3]{\left(\left(\sin \varepsilon \cdot \sin x\right) \cdot \left(\sin \varepsilon \cdot \sin x\right)\right) \cdot \left(\sin \varepsilon \cdot \sin x\right)}}{\cos \varepsilon \cdot \cos x}} - \tan x\\ \end{array}\]

Reproduce

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

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

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