\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -9.642672794131257633584719535235763032688 \cdot 10^{-5} \lor \neg \left(\varepsilon \le 4.975666270883717105063888360742797507804 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos x, \tan x + \tan \varepsilon, \sin x \cdot \left(-1 + \tan x \cdot \tan \varepsilon\right)\right)}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({\varepsilon}^{2}, \mathsf{fma}\left(\varepsilon, \frac{1}{3}, x\right), \varepsilon\right)\\
\end{array}double f(double x, double eps) {
double r150166 = x;
double r150167 = eps;
double r150168 = r150166 + r150167;
double r150169 = tan(r150168);
double r150170 = tan(r150166);
double r150171 = r150169 - r150170;
return r150171;
}
double f(double x, double eps) {
double r150172 = eps;
double r150173 = -9.642672794131258e-05;
bool r150174 = r150172 <= r150173;
double r150175 = 4.975666270883717e-20;
bool r150176 = r150172 <= r150175;
double r150177 = !r150176;
bool r150178 = r150174 || r150177;
double r150179 = x;
double r150180 = cos(r150179);
double r150181 = tan(r150179);
double r150182 = tan(r150172);
double r150183 = r150181 + r150182;
double r150184 = sin(r150179);
double r150185 = -1.0;
double r150186 = r150181 * r150182;
double r150187 = r150185 + r150186;
double r150188 = r150184 * r150187;
double r150189 = fma(r150180, r150183, r150188);
double r150190 = 1.0;
double r150191 = r150190 - r150186;
double r150192 = r150191 * r150180;
double r150193 = r150189 / r150192;
double r150194 = 2.0;
double r150195 = pow(r150172, r150194);
double r150196 = 0.3333333333333333;
double r150197 = fma(r150172, r150196, r150179);
double r150198 = fma(r150195, r150197, r150172);
double r150199 = r150178 ? r150193 : r150198;
return r150199;
}




Bits error versus x




Bits error versus eps
| Original | 37.1 |
|---|---|
| Target | 15.0 |
| Herbie | 13.5 |
if eps < -9.642672794131258e-05 or 4.975666270883717e-20 < eps Initial program 29.6
rmApplied tan-sum0.8
rmApplied tan-quot0.8
Applied frac-sub0.9
Simplified0.9
if -9.642672794131258e-05 < eps < 4.975666270883717e-20Initial program 45.1
rmApplied tan-sum44.8
Taylor expanded around inf 44.9
rmApplied div-inv44.9
Applied fma-neg44.9
Taylor expanded around 0 27.0
Simplified27.0
Final simplification13.5
herbie shell --seed 2019303 +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)))