\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -8.8270901166319843 \cdot 10^{-91}:\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \tan \varepsilon \cdot \tan x\right) \cdot \sin x}{\left(1 - \tan \varepsilon \cdot \tan x\right) \cdot \cos x}\\
\mathbf{elif}\;\varepsilon \le 1.47192102037964442 \cdot 10^{-77}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot \varepsilon, \varepsilon + x, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\tan x + \tan \varepsilon, \frac{-1}{\mathsf{fma}\left(\tan x, \tan \varepsilon, -1\right)}, -\tan x\right)\\
\end{array}double code(double x, double eps) {
return (tan((x + eps)) - tan(x));
}
double code(double x, double eps) {
double VAR;
if ((eps <= -8.827090116631984e-91)) {
VAR = ((((tan(x) + tan(eps)) * cos(x)) - ((1.0 - (tan(eps) * tan(x))) * sin(x))) / ((1.0 - (tan(eps) * tan(x))) * cos(x)));
} else {
double VAR_1;
if ((eps <= 1.4719210203796444e-77)) {
VAR_1 = fma((x * eps), (eps + x), eps);
} else {
VAR_1 = fma((tan(x) + tan(eps)), (-1.0 / fma(tan(x), tan(eps), -1.0)), -tan(x));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus eps
Results
| Original | 37.1 |
|---|---|
| Target | 15.4 |
| Herbie | 15.5 |
if eps < -8.827090116631984e-91Initial program 31.5
rmApplied tan-sum7.3
Simplified7.3
rmApplied tan-quot7.4
Applied frac-sub7.4
if -8.827090116631984e-91 < eps < 1.4719210203796444e-77Initial program 47.7
rmApplied tan-sum47.7
Simplified47.7
rmApplied div-inv47.7
Applied fma-neg47.7
Taylor expanded around 0 31.1
Simplified30.8
if 1.4719210203796444e-77 < eps Initial program 30.6
rmApplied tan-sum6.1
Simplified6.1
rmApplied div-inv6.1
Applied fma-neg6.1
rmApplied frac-2neg6.1
Simplified6.1
Final simplification15.5
herbie shell --seed 2020078 +o rules:numerics
(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)))