Average Error: 36.6 → 14.6
Time: 2.6m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -5.141666214214983 \cdot 10^{-54}:\\ \;\;\;\;\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.926096771495079 \cdot 10^{-17}:\\ \;\;\;\;{\varepsilon}^{3} \cdot {x}^{2} + \left(\varepsilon + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(e^{\tan x + \tan \varepsilon}\right)}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.6
Target14.7
Herbie14.6
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -5.141666214214983e-54

    1. Initial program 29.7

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

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

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

      \[\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 -5.141666214214983e-54 < eps < 1.926096771495079e-17

    1. Initial program 45.5

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Taylor expanded around 0 28.9

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

    if 1.926096771495079e-17 < eps

    1. Initial program 29.1

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

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

      \[\leadsto \frac{\tan x + \color{blue}{\log \left(e^{\tan \varepsilon}\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied add-log-exp2.1

      \[\leadsto \frac{\color{blue}{\log \left(e^{\tan x}\right)} + \log \left(e^{\tan \varepsilon}\right)}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    7. Applied sum-log2.1

      \[\leadsto \frac{\color{blue}{\log \left(e^{\tan x} \cdot e^{\tan \varepsilon}\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    8. Applied simplify2.1

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

Runtime

Time bar (total: 2.6m)Debug log

herbie shell --seed '#(2094665535 3654809497 1731717781 3082199462 566033875 575777438)' 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"
  :herbie-expected 28

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

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