Average Error: 36.9 → 9.7
Time: 33.2s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -2.2578813542634573 \cdot 10^{-52}:\\ \;\;\;\;\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}\\ \mathbf{if}\;\varepsilon \le 1.231202872879349 \cdot 10^{-44}:\\ \;\;\;\;\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.9
Comparison26.8
Herbie9.7
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -2.2578813542634573e-52

    1. Initial program 30.6

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

      \[\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 3.7

      \[\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 3.8

      \[\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 3.7

      \[\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 3.8

      \[\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 3.8

      \[\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}}\]

    if -2.2578813542634573e-52 < eps < 1.231202872879349e-44

    1. Initial program 46.2

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

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

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

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

    if 1.231202872879349e-44 < eps

    1. Initial program 30.9

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

      \[\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 3.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 3.7

      \[\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 3.7

      \[\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 3.8

      \[\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: 33.2s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1067488128 1186562765 67428877 2948030040 4169093828 3206893112)'
(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)))