\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -3.87985933356410738 \cdot 10^{-34} \lor \neg \left(\varepsilon \le 8.96237258412460441 \cdot 10^{-99}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{\frac{1 - \sqrt[3]{{\left({\left(\tan x \cdot \tan \varepsilon\right)}^{3}\right)}^{3}}}{\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) + 1}} - \tan x\\
\mathbf{else}:\\
\;\;\;\;x \cdot {\varepsilon}^{2} + \left(\varepsilon + {x}^{2} \cdot \varepsilon\right)\\
\end{array}double code(double x, double eps) {
return ((double) (((double) tan(((double) (x + eps)))) - ((double) tan(x))));
}
double code(double x, double eps) {
double VAR;
if (((eps <= -3.879859333564107e-34) || !(eps <= 8.962372584124604e-99))) {
VAR = ((double) ((((double) (((double) tan(x)) + ((double) tan(eps)))) / (((double) (1.0 - ((double) cbrt(((double) pow(((double) pow(((double) (((double) tan(x)) * ((double) tan(eps)))), 3.0)), 3.0)))))) / ((double) (((double) (((double) (((double) tan(x)) * ((double) tan(eps)))) * ((double) (1.0 + ((double) (((double) tan(x)) * ((double) tan(eps)))))))) + 1.0)))) - ((double) tan(x))));
} else {
VAR = ((double) (((double) (x * ((double) pow(eps, 2.0)))) + ((double) (eps + ((double) (((double) pow(x, 2.0)) * eps))))));
}
return VAR;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.8 |
|---|---|
| Target | 14.9 |
| Herbie | 16.0 |
if eps < -3.87985933356410738e-34 or 8.96237258412460441e-99 < eps Initial program 29.9
rmApplied tan-sum5.4
rmApplied flip3--5.5
Simplified5.5
Simplified5.5
rmApplied add-cbrt-cube5.5
Simplified5.5
if -3.87985933356410738e-34 < eps < 8.96237258412460441e-99Initial program 47.6
rmApplied tan-sum47.6
rmApplied flip3--47.6
Simplified47.6
Simplified47.6
Taylor expanded around 0 32.5
Final simplification16.0
herbie shell --seed 2020182
(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)))