Average Error: 36.7 → 13.3
Time: 1.8m
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.0863019201477782 \cdot 10^{-24}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \left(\sqrt[3]{\tan x}\right) + \left(\tan \varepsilon\right))_*}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\ \mathbf{if}\;\varepsilon \le 5.068526259562942 \cdot 10^{-24}:\\ \;\;\;\;(\left(x \cdot \varepsilon\right) \cdot \left((\left(x \cdot \varepsilon\right) \cdot \varepsilon + \varepsilon)_*\right) + \varepsilon)_*\\ \mathbf{else}:\\ \;\;\;\;(\left(\tan x + \tan \varepsilon\right) \cdot \left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right))_*\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.7
Target15.3
Herbie13.3
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -1.0863019201477782e-24

    1. Initial program 29.7

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

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\tan x} \cdot \sqrt[3]{\tan x}\right) \cdot \sqrt[3]{\tan x}} + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied fma-def1.9

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

    if -1.0863019201477782e-24 < eps < 5.068526259562942e-24

    1. Initial program 45.0

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

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

      \[\leadsto \color{blue}{(\left(x \cdot \varepsilon\right) \cdot \left((\left(x \cdot \varepsilon\right) \cdot \varepsilon + \varepsilon)_*\right) + \varepsilon)_*}\]

    if 5.068526259562942e-24 < eps

    1. Initial program 29.9

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

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

      \[\leadsto \color{blue}{\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    6. Applied fma-neg1.6

      \[\leadsto \color{blue}{(\left(\tan x + \tan \varepsilon\right) \cdot \left(\frac{1}{1 - \tan x \cdot \tan \varepsilon}\right) + \left(-\tan x\right))_*}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 1.8m)Debug logProfile

herbie shell --seed 2019053 +o rules:numerics
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

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

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