Average Error: 36.6 → 10.5
Time: 54.4s
Precision: 64
Ground Truth: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.5978287878901397 \cdot 10^{-47}:\\ \;\;\;\;\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}} - \tan x\\ \mathbf{if}\;\varepsilon \le 4.820454443524605 \cdot 10^{-45}:\\ \;\;\;\;\left(\varepsilon + {\varepsilon}^3 \cdot \left(x \cdot x\right)\right) + {x}^3 \cdot {\varepsilon}^{4}\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.6
Comparison26.5
Herbie10.5
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 3 regimes.
  2. if eps < -1.5978287878901397e-47

    1. Initial program 29.9

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied clear-num 4.2

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x\]

    if -1.5978287878901397e-47 < eps < 4.820454443524605e-45

    1. Initial program 46.2

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

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

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

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

    if 4.820454443524605e-45 < eps

    1. Initial program 29.5

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Using strategy rm
    3. Applied tan-sum 3.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 3.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 3.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 3.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\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Total time: 54.4s Debug log

Please include this information when filing a bug report:

herbie --seed '#(3916392738 3454683258 2683473460 599201605 346020274 3845347111)'
(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)))