Average Error: 36.6 → 15.0
Time: 1.7m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.7926102735642982 \cdot 10^{-37}:\\ \;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \sqrt[3]{\left(\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)\right) \cdot \left({\left(\sin x\right)}^{3} \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)\right)}}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \mathbf{if}\;\varepsilon \le 8.087235771864618 \cdot 10^{-51}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \log \left(e^{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}\right)}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Derivation

  1. Split input into 3 regimes
  2. if eps < -1.7926102735642982e-37

    1. Initial program 29.5

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

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

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

      \[\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}}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube3.0

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

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

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

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

    if -1.7926102735642982e-37 < eps < 8.087235771864618e-51

    1. Initial program 46.2

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

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

    if 8.087235771864618e-51 < eps

    1. Initial program 29.2

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

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

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

      \[\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}}\]
    6. Using strategy rm
    7. Applied add-log-exp4.3

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

Runtime

Time bar (total: 1.7m)Debug log

herbie shell --seed '#(1743936871 1855164119 3668777427 1254258049 132811564 1366975197)' 
(FPCore (x eps)
  :name "NMSE problem 3.3.2"
  (- (tan (+ x eps)) (tan x)))