\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.0222222222222222231, {x}^{3}, \mathsf{fma}\left(0.00211640211640211654, {x}^{5}, 0.333333333333333315 \cdot x\right)\right)double f(double x) {
double r150248 = 1.0;
double r150249 = x;
double r150250 = r150248 / r150249;
double r150251 = tan(r150249);
double r150252 = r150248 / r150251;
double r150253 = r150250 - r150252;
return r150253;
}
double f(double x) {
double r150254 = 0.022222222222222223;
double r150255 = x;
double r150256 = 3.0;
double r150257 = pow(r150255, r150256);
double r150258 = 0.0021164021164021165;
double r150259 = 5.0;
double r150260 = pow(r150255, r150259);
double r150261 = 0.3333333333333333;
double r150262 = r150261 * r150255;
double r150263 = fma(r150258, r150260, r150262);
double r150264 = fma(r150254, r150257, r150263);
return r150264;
}




Bits error versus x
| Original | 59.8 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
Initial program 59.8
Taylor expanded around 0 0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020036 +o rules:numerics
(FPCore (x)
:name "invcot (example 3.9)"
:precision binary64
: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))))