\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -3.99806522766741552 \cdot 10^{-18} \lor \neg \left(\varepsilon \le 7.73798919875330722 \cdot 10^{-19}\right):\\
\;\;\;\;\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\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\end{array}double code(double x, double eps) {
return (tan((x + eps)) - tan(x));
}
double code(double x, double eps) {
double temp;
if (((eps <= -3.9980652276674155e-18) || !(eps <= 7.737989198753307e-19))) {
temp = ((((tan(x) * tan(x)) - (tan(eps) * tan(eps))) / ((1.0 - (tan(x) * tan(eps))) * (tan(x) - tan(eps)))) - tan(x));
} else {
temp = (((eps * x) * (x + eps)) + eps);
}
return temp;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.9 |
|---|---|
| Target | 14.8 |
| Herbie | 15.2 |
if eps < -3.9980652276674155e-18 or 7.737989198753307e-19 < eps Initial program 29.4
rmApplied tan-sum1.0
rmApplied flip-+1.1
Applied associate-/l/1.1
if -3.9980652276674155e-18 < eps < 7.737989198753307e-19Initial program 44.9
Taylor expanded around 0 30.6
Simplified30.4
Final simplification15.2
herbie shell --seed 2020053
(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)))