\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -8.1479570759041135 \cdot 10^{-55}:\\
\;\;\;\;\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 1.56534825561633359 \cdot 10^{-66}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(\tan x + \tan \varepsilon\right) \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)\right) \cdot \cos x - \left(1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)\right) \cdot \sin x}{\left(1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)\right) \cdot \cos x}\\
\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.147957075904114e-55)) {
VAR = ((((tan(x) + tan(eps)) * cos(x)) - ((1.0 - (tan(x) * tan(eps))) * sin(x))) / ((1.0 - (tan(x) * tan(eps))) * cos(x)));
} else {
double VAR_1;
if ((eps <= 1.5653482556163336e-66)) {
VAR_1 = (((eps * x) * (x + eps)) + eps);
} else {
VAR_1 = (((((tan(x) + tan(eps)) * (1.0 + (tan(x) * tan(eps)))) * cos(x)) - ((1.0 - ((tan(x) * tan(eps)) * (tan(x) * tan(eps)))) * sin(x))) / ((1.0 - ((tan(x) * tan(eps)) * (tan(x) * tan(eps)))) * cos(x)));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.7 |
|---|---|
| Target | 14.8 |
| Herbie | 15.3 |
if eps < -8.147957075904114e-55Initial program 29.6
rmApplied tan-quot29.5
Applied tan-sum4.4
Applied frac-sub4.5
if -8.147957075904114e-55 < eps < 1.5653482556163336e-66Initial program 47.2
Taylor expanded around 0 31.1
Simplified30.9
if 1.5653482556163336e-66 < eps Initial program 29.9
rmApplied tan-sum5.4
rmApplied flip--5.4
Applied associate-/r/5.4
Simplified5.4
rmApplied tan-quot5.5
Applied associate-*l/5.5
Applied frac-sub5.5
Final simplification15.3
herbie shell --seed 2020105
(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)))