\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.4292982892743089 \cdot 10^{-72} \lor \neg \left(\varepsilon \le 7.895037822047127 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right) \cdot \sin x}{\left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right) \cdot \cos x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\varepsilon}^{2}, x, \mathsf{fma}\left(\varepsilon, {x}^{2}, \varepsilon\right)\right)\\
\end{array}double f(double x, double eps) {
double r106536 = x;
double r106537 = eps;
double r106538 = r106536 + r106537;
double r106539 = tan(r106538);
double r106540 = tan(r106536);
double r106541 = r106539 - r106540;
return r106541;
}
double f(double x, double eps) {
double r106542 = eps;
double r106543 = -1.429298289274309e-72;
bool r106544 = r106542 <= r106543;
double r106545 = 7.895037822047127e-70;
bool r106546 = r106542 <= r106545;
double r106547 = !r106546;
bool r106548 = r106544 || r106547;
double r106549 = x;
double r106550 = tan(r106549);
double r106551 = tan(r106542);
double r106552 = r106550 + r106551;
double r106553 = cos(r106549);
double r106554 = r106552 * r106553;
double r106555 = 1.0;
double r106556 = sin(r106549);
double r106557 = r106556 * r106551;
double r106558 = r106557 / r106553;
double r106559 = r106555 - r106558;
double r106560 = r106559 * r106556;
double r106561 = r106554 - r106560;
double r106562 = r106559 * r106553;
double r106563 = r106561 / r106562;
double r106564 = 2.0;
double r106565 = pow(r106542, r106564);
double r106566 = pow(r106549, r106564);
double r106567 = fma(r106542, r106566, r106542);
double r106568 = fma(r106565, r106549, r106567);
double r106569 = r106548 ? r106563 : r106568;
return r106569;
}




Bits error versus x




Bits error versus eps
| Original | 37.2 |
|---|---|
| Target | 15.3 |
| Herbie | 16.0 |
if eps < -1.429298289274309e-72 or 7.895037822047127e-70 < eps Initial program 31.1
rmApplied tan-sum6.5
rmApplied tan-quot6.5
Applied associate-*l/6.5
rmApplied tan-quot6.5
Applied frac-sub6.6
if -1.429298289274309e-72 < eps < 7.895037822047127e-70Initial program 47.3
Taylor expanded around 0 31.9
Simplified31.9
Final simplification16.0
herbie shell --seed 2020049 +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)))