\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -3.143684469318108724539290290060606314626 \cdot 10^{-82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos x, \tan x + \tan \varepsilon, \left(-1 + \tan x \cdot \tan \varepsilon\right) \cdot \sin x\right)}{\mathsf{fma}\left(\tan x, -\tan \varepsilon, 1\right) \cdot \cos x}\\
\mathbf{elif}\;\varepsilon \le 6.85981628349951691195956386637334831975 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon, x \cdot \left(\varepsilon + x\right), \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\tan x, -\tan \varepsilon, 1\right)}{\tan x + \tan \varepsilon}} - \tan x\\
\end{array}double f(double x, double eps) {
double r93320 = x;
double r93321 = eps;
double r93322 = r93320 + r93321;
double r93323 = tan(r93322);
double r93324 = tan(r93320);
double r93325 = r93323 - r93324;
return r93325;
}
double f(double x, double eps) {
double r93326 = eps;
double r93327 = -3.143684469318109e-82;
bool r93328 = r93326 <= r93327;
double r93329 = x;
double r93330 = cos(r93329);
double r93331 = tan(r93329);
double r93332 = tan(r93326);
double r93333 = r93331 + r93332;
double r93334 = -1.0;
double r93335 = r93331 * r93332;
double r93336 = r93334 + r93335;
double r93337 = sin(r93329);
double r93338 = r93336 * r93337;
double r93339 = fma(r93330, r93333, r93338);
double r93340 = -r93332;
double r93341 = 1.0;
double r93342 = fma(r93331, r93340, r93341);
double r93343 = r93342 * r93330;
double r93344 = r93339 / r93343;
double r93345 = 6.859816283499517e-40;
bool r93346 = r93326 <= r93345;
double r93347 = r93326 + r93329;
double r93348 = r93329 * r93347;
double r93349 = fma(r93326, r93348, r93326);
double r93350 = r93342 / r93333;
double r93351 = r93341 / r93350;
double r93352 = r93351 - r93331;
double r93353 = r93346 ? r93349 : r93352;
double r93354 = r93328 ? r93344 : r93353;
return r93354;
}




Bits error versus x




Bits error versus eps
| Original | 37.0 |
|---|---|
| Target | 15.1 |
| Herbie | 15.5 |
if eps < -3.143684469318109e-82Initial program 30.7
rmApplied tan-sum6.6
rmApplied *-un-lft-identity6.6
Applied *-un-lft-identity6.6
Applied times-frac6.6
Simplified6.6
Simplified6.6
rmApplied tan-quot6.6
Applied associate-*r/6.6
Applied frac-sub6.6
Simplified6.6
if -3.143684469318109e-82 < eps < 6.859816283499517e-40Initial program 47.2
Taylor expanded around 0 31.2
Simplified31.2
if 6.859816283499517e-40 < eps Initial program 29.6
rmApplied tan-sum3.2
rmApplied *-un-lft-identity3.2
Applied *-un-lft-identity3.2
Applied times-frac3.2
Simplified3.2
Simplified3.2
rmApplied clear-num3.3
Final simplification15.5
herbie shell --seed 2019304 +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)))