\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -5.97198873028037458 \cdot 10^{-27} \lor \neg \left(\varepsilon \le 4.74228187640458693 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{\log \left({e}^{\left(1 - \tan x \cdot \tan \varepsilon\right)} \cdot {e}^{\left(\mathsf{fma}\left(-\tan \varepsilon, \tan x, \tan \varepsilon \cdot \tan x\right)\right)}\right)} - \tan x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\varepsilon}^{2}, x, \mathsf{fma}\left(\varepsilon, {x}^{2}, \varepsilon\right)\right)\\
\end{array}double code(double x, double eps) {
return (tan((x + eps)) - tan(x));
}
double code(double x, double eps) {
double temp;
if (((eps <= -5.9719887302803746e-27) || !(eps <= 4.742281876404587e-23))) {
temp = (((tan(x) + tan(eps)) / log((pow(((double) M_E), (1.0 - (tan(x) * tan(eps)))) * pow(((double) M_E), fma(-tan(eps), tan(x), (tan(eps) * tan(x))))))) - tan(x));
} else {
temp = fma(pow(eps, 2.0), x, fma(eps, pow(x, 2.0), eps));
}
return temp;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.8 |
|---|---|
| Target | 15.2 |
| Herbie | 15.2 |
if eps < -5.9719887302803746e-27 or 4.742281876404587e-23 < eps Initial program 29.8
rmApplied tan-sum1.7
rmApplied add-log-exp1.8
Applied add-log-exp1.8
Applied diff-log1.9
Simplified1.8
rmApplied *-un-lft-identity1.8
Applied exp-prod1.9
Simplified1.9
rmApplied add-cube-cbrt1.9
Applied prod-diff1.9
Applied unpow-prod-up1.9
Simplified1.9
if -5.9719887302803746e-27 < eps < 4.742281876404587e-23Initial program 45.1
Taylor expanded around 0 30.9
Simplified30.9
Final simplification15.2
herbie shell --seed 2020057 +o rules:numerics
(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)))