Average Error: 37.5 → 14.4
Time: 1.3m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le -4.873817797528772 \cdot 10^{-31}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x}\right)}^{3}} - \tan x\\ \mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le 4.386919576830508 \cdot 10^{-21}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \left(\tan x \cdot \left(\sqrt[3]{\tan \varepsilon} \cdot \sqrt[3]{\tan \varepsilon}\right)\right) \cdot \sqrt[3]{\tan \varepsilon}} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original37.5
Target15.4
Herbie14.4
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < -4.873817797528772e-31

    1. Initial program 36.3

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{\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)}}} - \tan x\]
    6. Applied add-cbrt-cube10.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\tan x + \tan \varepsilon\right) \cdot \left(\tan x + \tan \varepsilon\right)\right) \cdot \left(\tan x + \tan \varepsilon\right)}}}{\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)}} - \tan x\]
    7. Applied cbrt-undiv10.4

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \left(\tan x + \tan \varepsilon\right)\right) \cdot \left(\tan x + \tan \varepsilon\right)}{\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)}}} - \tan x\]
    8. Applied simplify10.4

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

    if -4.873817797528772e-31 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < 4.386919576830508e-21

    1. Initial program 39.9

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

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

    if 4.386919576830508e-21 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x)))

    1. Initial program 36.3

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\left(\left(\sqrt[3]{\tan \varepsilon} \cdot \sqrt[3]{\tan \varepsilon}\right) \cdot \sqrt[3]{\tan \varepsilon}\right)}} - \tan x\]
    6. Applied associate-*r*14.7

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

Runtime

Time bar (total: 1.3m)Debug logProfile

herbie shell --seed '#(1070609872 3456127585 2380521889 2328837196 1765472538 734540918)' 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

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

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