\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -2.5520522219363244 \cdot 10^{-74} \lor \neg \left(\varepsilon \leq 2.207117436105011 \cdot 10^{-19}\right):\\
\;\;\;\;\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + \left(\varepsilon + x\right) \cdot \left(\varepsilon \cdot x\right)\\
\end{array}(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
(FPCore (x eps) :precision binary64 (if (or (<= eps -2.5520522219363244e-74) (not (<= eps 2.207117436105011e-19))) (- (* (+ (tan x) (tan eps)) (/ 1.0 (- 1.0 (* (tan x) (tan eps))))) (tan x)) (+ eps (* (+ eps x) (* eps x)))))
double code(double x, double eps) {
return tan(x + eps) - tan(x);
}
double code(double x, double eps) {
double tmp;
if ((eps <= -2.5520522219363244e-74) || !(eps <= 2.207117436105011e-19)) {
tmp = ((tan(x) + tan(eps)) * (1.0 / (1.0 - (tan(x) * tan(eps))))) - tan(x);
} else {
tmp = eps + ((eps + x) * (eps * x));
}
return tmp;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.6 |
|---|---|
| Target | 15.3 |
| Herbie | 15.3 |
if eps < -2.55205222193632443e-74 or 2.20711743610501114e-19 < eps Initial program 30.4
rmApplied tan-sum_binary64_15903.8
rmApplied div-inv_binary64_14523.9
if -2.55205222193632443e-74 < eps < 2.20711743610501114e-19Initial program 45.1
Taylor expanded around 0 31.0
Simplified30.8
Final simplification15.3
herbie shell --seed 2020288
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:precision binary64
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))