\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 r122593 = 1.0;
double r122594 = x;
double r122595 = r122593 / r122594;
double r122596 = tan(r122594);
double r122597 = r122593 / r122596;
double r122598 = r122595 - r122597;
return r122598;
}
double f(double x) {
double r122599 = 0.022222222222222223;
double r122600 = x;
double r122601 = 3.0;
double r122602 = pow(r122600, r122601);
double r122603 = 0.0021164021164021165;
double r122604 = 5.0;
double r122605 = pow(r122600, r122604);
double r122606 = 0.3333333333333333;
double r122607 = r122606 * r122600;
double r122608 = fma(r122603, r122605, r122607);
double r122609 = fma(r122599, r122602, r122608);
return r122609;
}




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 2019235 +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))))