\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -7.5761833452932248 \cdot 10^{-22}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{\log \left(e^{1 - \tan x \cdot \tan \varepsilon}\right)} - \tan x\\
\mathbf{elif}\;\varepsilon \le 1.0303244886229992 \cdot 10^{-49}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}} - \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 <= -7.576183345293225e-22)) {
VAR = ((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) / ((double) log(((double) exp(((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))))))))) - ((double) tan(x))));
} else {
double VAR_1;
if ((eps <= 1.0303244886229992e-49)) {
VAR_1 = ((double) (((double) (((double) (eps * x)) * ((double) (x + eps)))) + eps));
} else {
VAR_1 = ((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) / ((double) (1.0 - ((double) (((double) (((double) sin(x)) * ((double) tan(eps)))) / ((double) cos(x)))))))) - ((double) tan(x))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.8 |
|---|---|
| Target | 14.9 |
| Herbie | 15.5 |
if eps < -7.5761833452932248e-22Initial program 29.2
rmApplied tan-sum1.3
rmApplied add-log-exp1.4
Applied add-log-exp1.4
Applied diff-log1.4
Simplified1.4
if -7.5761833452932248e-22 < eps < 1.0303244886229992e-49Initial program 45.6
Taylor expanded around 0 31.4
Simplified31.2
if 1.0303244886229992e-49 < eps Initial program 30.4
rmApplied tan-sum4.5
rmApplied tan-quot4.5
Applied associate-*l/4.5
Final simplification15.5
herbie shell --seed 2020174
(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)))