\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 r68946 = 1.0;
double r68947 = x;
double r68948 = r68946 / r68947;
double r68949 = tan(r68947);
double r68950 = r68946 / r68949;
double r68951 = r68948 - r68950;
return r68951;
}
double f(double x) {
double r68952 = 0.022222222222222223;
double r68953 = x;
double r68954 = 3.0;
double r68955 = pow(r68953, r68954);
double r68956 = 0.0021164021164021165;
double r68957 = 5.0;
double r68958 = pow(r68953, r68957);
double r68959 = 0.3333333333333333;
double r68960 = r68959 * r68953;
double r68961 = fma(r68956, r68958, r68960);
double r68962 = fma(r68952, r68955, r68961);
return r68962;
}




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