Average Error: 36.1 → 8.7
Time: 42.6s
Precision: 64
Internal precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -3.151429688885422 \cdot 10^{-36}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sqrt[3]{{\left(\sin x\right)}^3 \cdot {\left(\sin \varepsilon\right)}^3}}{\sqrt[3]{{\left(\cos x\right)}^3 \cdot {\left(\cos \varepsilon\right)}^3}}} - \tan x\\ \mathbf{if}\;\varepsilon \le 2.4432831384469056 \cdot 10^{-19}:\\ \;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}\right) \cdot \sin x}{\left(1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}\right) \cdot \cos x}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.1
Comparison26.8
Herbie8.7
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -3.151429688885422e-36

    1. Initial program 30.6

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\sqrt[3]{{\left(\tan \varepsilon\right)}^3}}} - \tan x\]
    6. Applied add-cbrt-cube 2.7

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3}} \cdot \sqrt[3]{{\left(\tan \varepsilon\right)}^3}} - \tan x\]
    7. Applied cbrt-unprod 2.6

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}} - \tan x\]
    8. Using strategy rm
    9. Applied tan-quot 2.6

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

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

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

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

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

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

    if -3.151429688885422e-36 < eps < 2.4432831384469056e-19

    1. Initial program 44.1

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

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

      \[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
    4. Applied simplify 17.5

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

    if 2.4432831384469056e-19 < eps

    1. Initial program 29.3

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Using strategy rm
    3. Applied tan-sum 1.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-cube 1.2

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\sqrt[3]{{\left(\tan \varepsilon\right)}^3}}} - \tan x\]
    6. Applied add-cbrt-cube 1.2

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3}} \cdot \sqrt[3]{{\left(\tan \varepsilon\right)}^3}} - \tan x\]
    7. Applied cbrt-unprod 1.2

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}} - \tan x\]
    8. Using strategy rm
    9. Applied tan-quot 1.3

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

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

Runtime

Time bar (total: 42.6s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064651971 495577305 2200811460 13024471 864198081 231948279)'
(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)))