\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 r139991 = 1.0;
double r139992 = x;
double r139993 = r139991 / r139992;
double r139994 = tan(r139992);
double r139995 = r139991 / r139994;
double r139996 = r139993 - r139995;
return r139996;
}
double f(double x) {
double r139997 = 0.022222222222222223;
double r139998 = x;
double r139999 = 3.0;
double r140000 = pow(r139998, r139999);
double r140001 = 0.0021164021164021165;
double r140002 = 5.0;
double r140003 = pow(r139998, r140002);
double r140004 = 0.3333333333333333;
double r140005 = r140004 * r139998;
double r140006 = fma(r140001, r140003, r140005);
double r140007 = fma(r139997, r140000, r140006);
return r140007;
}




Bits error versus x
| Original | 60.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 60.0
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019209 +o rules:numerics
(FPCore (x)
:name "invcot (example 3.9)"
:precision binary64
:pre (and (< -0.0259999999999999988 x) (< x 0.0259999999999999988))
:herbie-target
(if (< (fabs x) 0.0259999999999999988) (* (/ x 3) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))
(- (/ 1 x) (/ 1 (tan x))))