Average Error: 36.5 → 10.1
Time: 30.1s
Precision: 64
Internal precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.2060971230698667 \cdot 10^{-61}:\\ \;\;\;\;\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 1.6177319322054696 \cdot 10^{-26}:\\ \;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{\left(\tan x\right)}^2 - {\left(\tan \varepsilon\right)}^2}{\tan x - \tan \varepsilon}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

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

Derivation

  1. Split input into 3 regimes.
  2. if eps < -1.2060971230698667e-61

    1. Initial program 29.8

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

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

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

      \[\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 -1.2060971230698667e-61 < eps < 1.6177319322054696e-26

    1. Initial program 45.8

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

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

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

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

    if 1.6177319322054696e-26 < eps

    1. Initial program 29.5

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

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

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

Runtime

Time bar (total: 30.1s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1067615470 1817955187 3564058462 2385304812 1026693554 2746013648)'
(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)))