\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(\frac{2}{945}, {x}^{5}, \frac{x}{\frac{\frac{\frac{1}{3} - \left(\frac{1}{45} \cdot x\right) \cdot x}{\mathsf{fma}\left(\frac{1}{45} \cdot x, x, \frac{1}{3}\right)}}{\frac{1}{3} - \left(\frac{1}{45} \cdot x\right) \cdot x}}\right)double f(double x) {
double r5372401 = 1.0;
double r5372402 = x;
double r5372403 = r5372401 / r5372402;
double r5372404 = tan(r5372402);
double r5372405 = r5372401 / r5372404;
double r5372406 = r5372403 - r5372405;
return r5372406;
}
double f(double x) {
double r5372407 = 0.0021164021164021165;
double r5372408 = x;
double r5372409 = 5.0;
double r5372410 = pow(r5372408, r5372409);
double r5372411 = 0.3333333333333333;
double r5372412 = 0.022222222222222223;
double r5372413 = r5372412 * r5372408;
double r5372414 = r5372413 * r5372408;
double r5372415 = r5372411 - r5372414;
double r5372416 = fma(r5372413, r5372408, r5372411);
double r5372417 = r5372415 / r5372416;
double r5372418 = r5372417 / r5372415;
double r5372419 = r5372408 / r5372418;
double r5372420 = fma(r5372407, r5372410, r5372419);
return r5372420;
}




Bits error versus x
| Original | 60.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 60.0
Taylor expanded around 0 0.3
Simplified0.3
Taylor expanded around -inf 0.3
Simplified0.3
rmApplied flip-+0.3
Applied associate-*r/0.3
rmApplied associate-/l*0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2019134 +o rules:numerics
(FPCore (x)
:name "invcot (example 3.9)"
:pre (and (< -0.026 x) (< x 0.026))
:herbie-target
(if (< (fabs x) 0.026) (* (/ x 3) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))
(- (/ 1 x) (/ 1 (tan x))))