Average Error: 36.2 → 9.1
Time: 54.3s
Precision: 64
Internal precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -8.215474236625967 \cdot 10^{-36}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\ \mathbf{if}\;\varepsilon \le 1.097745022759887 \cdot 10^{-20}:\\ \;\;\;\;\left(\varepsilon + {\varepsilon}^{4} \cdot {x}^3\right) + \left(x \cdot x\right) \cdot {\varepsilon}^3\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.2
Comparison26.7
Herbie9.1
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]

Derivation

  1. Split input into 2 regimes.
  2. if eps < -8.215474236625967e-36 or 1.097745022759887e-20 < eps

    1. Initial program 29.9

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
    6. Applied associate-*r/ 2.0

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

    if -8.215474236625967e-36 < eps < 1.097745022759887e-20

    1. Initial program 43.9

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

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

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

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

Runtime

Time bar (total: 54.3s) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(3283856077 3183919125 3399458751 396155847 3688194147 1862413033)'
(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)))