\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -3.63980888889557201 \cdot 10^{-18}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon}} - \tan x\\
\mathbf{elif}\;\varepsilon \le 1.2121002027987652 \cdot 10^{-17}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x \cdot \tan x - \tan \varepsilon \cdot \tan \varepsilon}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x - \tan \varepsilon\right)} - \tan x\\
\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.639808888895572e-18)) {
VAR = ((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) / ((double) (1.0 - ((double) (((double) (((double) sin(x)) * ((double) sin(eps)))) / ((double) (((double) cos(x)) * ((double) cos(eps)))))))))) - ((double) tan(x))));
} else {
double VAR_1;
if ((eps <= 1.2121002027987652e-17)) {
VAR_1 = ((double) (((double) (((double) (eps * x)) * ((double) (x + eps)))) + eps));
} else {
VAR_1 = ((double) (((double) (((double) (((double) (((double) tan(x)) * ((double) tan(x)))) - ((double) (((double) tan(eps)) * ((double) tan(eps)))))) / ((double) (((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))) * ((double) (((double) tan(x)) - ((double) tan(eps)))))))) - ((double) tan(x))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.5 |
|---|---|
| Target | 14.9 |
| Herbie | 15.2 |
if eps < -3.639808888895572e-18Initial program 29.0
rmApplied tan-sum0.8
rmApplied tan-quot0.8
Applied tan-quot0.8
Applied frac-times0.8
if -3.639808888895572e-18 < eps < 1.2121002027987652e-17Initial program 44.7
Taylor expanded around 0 31.3
Simplified31.1
if 1.2121002027987652e-17 < eps Initial program 29.5
rmApplied tan-sum1.0
rmApplied flip-+1.1
Applied associate-/l/1.1
Final simplification15.2
herbie shell --seed 2020123
(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)))