Average Error: 37.2 → 14.2
Time: 55.9s
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right) \le -3.1350503730749374 \cdot 10^{-24}:\\ \;\;\;\;\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \sin x\right) + \tan x \cdot \left(\tan \varepsilon \cdot \sin x\right)}{\cos x - \left(\cos x \cdot \tan \varepsilon\right) \cdot \tan x}\\ \mathbf{elif}\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right) \le 1.965314832370709 \cdot 10^{-138}:\\ \;\;\;\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \sin x\right) + \tan x \cdot \left(\tan \varepsilon \cdot \sin x\right)}{\cos x - \left(\cos x \cdot \tan \varepsilon\right) \cdot \tan x}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (+ (* x (pow eps 2)) (+ eps (* 1/3 (* (pow x 2) (pow eps 3))))) < -3.1350503730749374e-24 or 1.965314832370709e-138 < (+ (* x (pow eps 2)) (+ eps (* 1/3 (* (pow x 2) (pow eps 3)))))

    1. Initial program 35.1

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Initial simplification35.1

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

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

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

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \color{blue}{\sqrt[3]{\left(\tan \varepsilon \cdot \tan \varepsilon\right) \cdot \tan \varepsilon}} \cdot \sqrt[3]{\left(\tan x \cdot \tan x\right) \cdot \tan x}} - \tan x\]
    8. Applied cbrt-unprod14.5

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

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \sqrt[3]{\color{blue}{{\left(\tan x \cdot \tan \varepsilon\right)}^{3}}}} - \tan x\]
    10. Using strategy rm
    11. Applied cube-prod14.5

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

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

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \color{blue}{\tan x} \cdot \sqrt[3]{{\left(\tan \varepsilon\right)}^{3}}} - \tan x\]
    14. Using strategy rm
    15. Applied tan-quot14.6

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

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

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

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

    if -3.1350503730749374e-24 < (+ (* x (pow eps 2)) (+ eps (* 1/3 (* (pow x 2) (pow eps 3))))) < 1.965314832370709e-138

    1. Initial program 42.8

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Initial simplification42.8

      \[\leadsto \tan \left(\varepsilon + x\right) - \tan x\]
    3. Using strategy rm
    4. Applied tan-sum42.8

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

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

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

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

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

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

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

      \[\leadsto \frac{\tan \varepsilon + \tan x}{1 - \color{blue}{\tan x} \cdot \sqrt[3]{{\left(\tan \varepsilon\right)}^{3}}} - \tan x\]
    14. Taylor expanded around 0 16.6

      \[\leadsto \color{blue}{x \cdot {\varepsilon}^{2} + \left(\varepsilon + \frac{1}{3} \cdot \left({x}^{2} \cdot {\varepsilon}^{3}\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right) \le -3.1350503730749374 \cdot 10^{-24}:\\ \;\;\;\;\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \sin x\right) + \tan x \cdot \left(\tan \varepsilon \cdot \sin x\right)}{\cos x - \left(\cos x \cdot \tan \varepsilon\right) \cdot \tan x}\\ \mathbf{elif}\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right) \le 1.965314832370709 \cdot 10^{-138}:\\ \;\;\;\;{\varepsilon}^{2} \cdot x + \left(\varepsilon + \left({x}^{2} \cdot {\varepsilon}^{3}\right) \cdot \frac{1}{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \sin x\right) + \tan x \cdot \left(\tan \varepsilon \cdot \sin x\right)}{\cos x - \left(\cos x \cdot \tan \varepsilon\right) \cdot \tan x}\\ \end{array}\]

Runtime

Time bar (total: 55.9s)Debug logProfile

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

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

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