Average Error: 37.3 → 11.0
Time: 2.0m
Precision: 64
Ground Truth: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -6.041808348837433 \cdot 10^{-43}:\\ \;\;\;\;\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}\\ \mathbf{if}\;\varepsilon \le 3.290445875832927 \cdot 10^{-111}:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{\tan \varepsilon + \tan x}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}\right)}^3 - {\left(\tan x\right)}^3}{{\left(\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}\right)}^2 + \left({\left(\tan x\right)}^2 + \frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}} \cdot \tan x\right)}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original37.3
Comparison25.6
Herbie11.0
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -6.041808348837433e-43

    1. Initial program 31.4

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

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

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

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

    if -6.041808348837433e-43 < eps < 3.290445875832927e-111

    1. Initial program 47.6

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

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

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

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

    if 3.290445875832927e-111 < eps

    1. Initial program 31.2

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

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

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

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

      \[\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 flip3-- 8.8

      \[\leadsto \color{blue}{\frac{{\left(\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}\right)}^{3} - {\left(\tan x\right)}^{3}}{{\left(\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}\right)}^2 + \left({\left(\tan x\right)}^2 + \frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}} \cdot \tan x\right)}}\]
    10. Applied simplify 8.8

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

Runtime

Total time: 2.0m Debug log

Please include this information when filing a bug report:

herbie --seed '#(1760188614 120530851 1113714957 3291444970 1127176104 4016628637)'
(FPCore (x eps)
  :name "NMSE problem 3.3.2"
  :herbie-expected 28

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

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