\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.02222222222222222307030925492199457949027, {x}^{3}, \mathsf{fma}\left(0.002116402116402116544841005563171165704262, {x}^{5}, 0.3333333333333333148296162562473909929395 \cdot x\right)\right)double f(double x) {
double r91610 = 1.0;
double r91611 = x;
double r91612 = r91610 / r91611;
double r91613 = tan(r91611);
double r91614 = r91610 / r91613;
double r91615 = r91612 - r91614;
return r91615;
}
double f(double x) {
double r91616 = 0.022222222222222223;
double r91617 = x;
double r91618 = 3.0;
double r91619 = pow(r91617, r91618);
double r91620 = 0.0021164021164021165;
double r91621 = 5.0;
double r91622 = pow(r91617, r91621);
double r91623 = 0.3333333333333333;
double r91624 = r91623 * r91617;
double r91625 = fma(r91620, r91622, r91624);
double r91626 = fma(r91616, r91619, r91625);
return r91626;
}




Bits error versus x
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 59.9
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2020002 +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))))