Average Error: 36.3 → 9.5
Time: 2.1m
Precision: 64
Ground Truth: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -9.637689048663334 \cdot 10^{-40}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - {\left(\sqrt[3]{\tan x \cdot \tan \varepsilon}\right)}^3} - \tan x\\ \mathbf{if}\;\varepsilon \le 4.6574913990588864 \cdot 10^{-35}:\\ \;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{\tan \varepsilon + \tan x}{1 - \tan \varepsilon \cdot \tan x}\right)}^3 - {\left(\tan x\right)}^3}{{\left(\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}\right)}^2 + \left({\left(\tan x\right)}^2 + \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} \cdot \tan x\right)}\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if eps < -9.637689048663334e-40

    1. Initial program 29.8

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

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

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

    if -9.637689048663334e-40 < eps < 4.6574913990588864e-35

    1. Initial program 45.4

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

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

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

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

    if 4.6574913990588864e-35 < eps

    1. Initial program 29.5

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

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

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

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

Runtime

Total time: 2.1m Debug log

Please include this information when filing a bug report:

herbie --seed '#(2693639736 2992660235 1326515755 2365531599 3256411085 3202136504)'
(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)))