\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -2.22121376769650082 \cdot 10^{-17}:\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\
\mathbf{elif}\;\varepsilon \le 3.48145867597643924 \cdot 10^{-112}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x \cdot \tan x - \tan \varepsilon \cdot \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{1}{\tan x - \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 <= -2.2212137676965008e-17)) {
VAR = ((double) (((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) * ((double) cos(x)))) - ((double) (((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))) * ((double) sin(x)))))) / ((double) (((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))) * ((double) cos(x))))));
} else {
double VAR_1;
if ((eps <= 3.4814586759764392e-112)) {
VAR_1 = ((double) (((double) (((double) (eps * x)) * ((double) (x + eps)))) + eps));
} else {
VAR_1 = ((double) (((double) (((double) (((double) (((double) (((double) tan(x)) * ((double) tan(x)))) - ((double) (((double) tan(eps)) * ((double) tan(eps)))))) / ((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))))) * ((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.6 |
|---|---|
| Target | 15.0 |
| Herbie | 15.5 |
if eps < -2.2212137676965008e-17Initial program 28.7
rmApplied tan-quot28.6
Applied tan-sum1.0
Applied frac-sub1.1
if -2.2212137676965008e-17 < eps < 3.4814586759764392e-112Initial program 46.3
Taylor expanded around 0 31.0
Simplified30.8
if 3.4814586759764392e-112 < eps Initial program 31.4
rmApplied tan-sum8.7
rmApplied clear-num8.8
rmApplied flip-+8.9
Applied associate-/r/9.0
Applied add-cube-cbrt9.0
Applied times-frac9.0
Simplified8.9
Simplified8.9
Final simplification15.5
herbie shell --seed 2020140
(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)))