\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.44770063686003076 \cdot 10^{-29}:\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \frac{1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)}{1 + \tan x \cdot \tan \varepsilon} \cdot \sin x}{\frac{1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)}{1 + \tan x \cdot \tan \varepsilon} \cdot \cos x}\\
\mathbf{elif}\;\varepsilon \le 1.26608976468615072 \cdot 10^{-42}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{\frac{1 - \frac{\left(\tan x \cdot \tan x\right) \cdot {\left(\sin \varepsilon\right)}^{2}}{{\left(\cos \varepsilon\right)}^{2}}}{1 + \tan x \cdot \tan \varepsilon}} - \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 <= -1.4477006368600308e-29)) {
VAR = ((double) (((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) * ((double) cos(x)))) - ((double) (((double) (((double) (1.0 - ((double) (((double) (((double) tan(x)) * ((double) tan(eps)))) * ((double) (((double) tan(x)) * ((double) tan(eps)))))))) / ((double) (1.0 + ((double) (((double) tan(x)) * ((double) tan(eps)))))))) * ((double) sin(x)))))) / ((double) (((double) (((double) (1.0 - ((double) (((double) (((double) tan(x)) * ((double) tan(eps)))) * ((double) (((double) tan(x)) * ((double) tan(eps)))))))) / ((double) (1.0 + ((double) (((double) tan(x)) * ((double) tan(eps)))))))) * ((double) cos(x))))));
} else {
double VAR_1;
if ((eps <= 1.2660897646861507e-42)) {
VAR_1 = ((double) (((double) (((double) (eps * x)) * ((double) (x + eps)))) + eps));
} else {
VAR_1 = ((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) / ((double) (((double) (1.0 - ((double) (((double) (((double) (((double) tan(x)) * ((double) tan(x)))) * ((double) pow(((double) sin(eps)), 2.0)))) / ((double) pow(((double) cos(eps)), 2.0)))))) / ((double) (1.0 + ((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.9 |
|---|---|
| Target | 15.1 |
| Herbie | 15.2 |
if eps < -1.4477006368600308e-29Initial program 28.8
rmApplied tan-sum2.0
rmApplied flip--2.0
Simplified2.0
rmApplied tan-quot2.1
Applied frac-sub2.1
if -1.4477006368600308e-29 < eps < 1.2660897646861507e-42Initial program 45.8
Taylor expanded around 0 31.1
Simplified30.9
if 1.2660897646861507e-42 < eps Initial program 30.8
rmApplied tan-sum3.4
rmApplied flip--3.4
Simplified3.4
rmApplied tan-quot3.4
Applied associate-*r/3.5
Applied tan-quot3.5
Applied associate-*r/3.5
Applied frac-times3.5
Simplified3.5
Simplified3.5
Final simplification15.2
herbie shell --seed 2020130
(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)))