\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.90524906925258064 \cdot 10^{-75}:\\
\;\;\;\;\left(\left(\tan x + \tan \varepsilon\right) \cdot \frac{1}{1 - \log \left(e^{\frac{\sin x \cdot \tan \varepsilon}{\cos x}}\right)} - \tan x\right) + \mathsf{fma}\left(-\tan x, 1, \tan x\right)\\
\mathbf{elif}\;\varepsilon \le 1.8371289099221047 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left({\varepsilon}^{2}, x, \mathsf{fma}\left(\varepsilon, {x}^{2}, \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\sin x, \cos \varepsilon, \cos x \cdot \sin \varepsilon\right), \cos x, -\left(\left(\cos x \cdot \cos \varepsilon\right) \cdot \left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right)\right) \cdot \sin x\right)}{\left(\left(\cos x \cdot \cos \varepsilon\right) \cdot \left(1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}\right)\right) \cdot \cos x} + \mathsf{fma}\left(-\tan x, 1, \tan x\right)\\
\end{array}double f(double x, double eps) {
double r166221 = x;
double r166222 = eps;
double r166223 = r166221 + r166222;
double r166224 = tan(r166223);
double r166225 = tan(r166221);
double r166226 = r166224 - r166225;
return r166226;
}
double f(double x, double eps) {
double r166227 = eps;
double r166228 = -1.9052490692525806e-75;
bool r166229 = r166227 <= r166228;
double r166230 = x;
double r166231 = tan(r166230);
double r166232 = tan(r166227);
double r166233 = r166231 + r166232;
double r166234 = 1.0;
double r166235 = sin(r166230);
double r166236 = r166235 * r166232;
double r166237 = cos(r166230);
double r166238 = r166236 / r166237;
double r166239 = exp(r166238);
double r166240 = log(r166239);
double r166241 = r166234 - r166240;
double r166242 = r166234 / r166241;
double r166243 = r166233 * r166242;
double r166244 = r166243 - r166231;
double r166245 = -r166231;
double r166246 = fma(r166245, r166234, r166231);
double r166247 = r166244 + r166246;
double r166248 = 1.8371289099221047e-44;
bool r166249 = r166227 <= r166248;
double r166250 = 2.0;
double r166251 = pow(r166227, r166250);
double r166252 = pow(r166230, r166250);
double r166253 = fma(r166227, r166252, r166227);
double r166254 = fma(r166251, r166230, r166253);
double r166255 = cos(r166227);
double r166256 = sin(r166227);
double r166257 = r166237 * r166256;
double r166258 = fma(r166235, r166255, r166257);
double r166259 = r166237 * r166255;
double r166260 = r166234 - r166238;
double r166261 = r166259 * r166260;
double r166262 = r166261 * r166235;
double r166263 = -r166262;
double r166264 = fma(r166258, r166237, r166263);
double r166265 = r166261 * r166237;
double r166266 = r166264 / r166265;
double r166267 = r166266 + r166246;
double r166268 = r166249 ? r166254 : r166267;
double r166269 = r166229 ? r166247 : r166268;
return r166269;
}




Bits error versus x




Bits error versus eps
| Original | 37.6 |
|---|---|
| Target | 15.4 |
| Herbie | 15.6 |
if eps < -1.9052490692525806e-75Initial program 30.2
rmApplied tan-sum6.0
rmApplied tan-quot6.0
Applied associate-*l/6.0
rmApplied add-cube-cbrt6.3
Applied div-inv6.3
Applied prod-diff6.3
Simplified6.0
Simplified6.1
rmApplied add-log-exp6.2
if -1.9052490692525806e-75 < eps < 1.8371289099221047e-44Initial program 47.3
Taylor expanded around 0 31.3
Simplified31.3
if 1.8371289099221047e-44 < eps Initial program 31.4
rmApplied tan-sum2.6
rmApplied tan-quot2.7
Applied associate-*l/2.6
rmApplied add-cube-cbrt3.0
Applied div-inv3.0
Applied prod-diff3.0
Simplified2.6
Simplified2.7
rmApplied tan-quot2.7
Applied tan-quot2.9
Applied tan-quot2.8
Applied frac-add2.9
Applied frac-times2.9
Applied frac-sub2.9
Simplified2.8
Final simplification15.6
herbie shell --seed 2020036 +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)))