\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.02222222222222222307030925492199457949027, {x}^{3}, \mathsf{fma}\left(0.3333333333333333148296162562473909929395, x, 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\right)\right)double f(double x) {
double r91998 = 1.0;
double r91999 = x;
double r92000 = r91998 / r91999;
double r92001 = tan(r91999);
double r92002 = r91998 / r92001;
double r92003 = r92000 - r92002;
return r92003;
}
double f(double x) {
double r92004 = 0.022222222222222223;
double r92005 = x;
double r92006 = 3.0;
double r92007 = pow(r92005, r92006);
double r92008 = 0.3333333333333333;
double r92009 = 0.0021164021164021165;
double r92010 = 5.0;
double r92011 = pow(r92005, r92010);
double r92012 = r92009 * r92011;
double r92013 = fma(r92008, r92005, r92012);
double r92014 = fma(r92004, r92007, r92013);
return r92014;
}




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
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019194 +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.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))
(- (/ 1.0 x) (/ 1.0 (tan x))))