\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 r187624 = 1.0;
double r187625 = x;
double r187626 = r187624 / r187625;
double r187627 = tan(r187625);
double r187628 = r187624 / r187627;
double r187629 = r187626 - r187628;
return r187629;
}
double f(double x) {
double r187630 = 0.022222222222222223;
double r187631 = x;
double r187632 = 3.0;
double r187633 = pow(r187631, r187632);
double r187634 = 0.0021164021164021165;
double r187635 = 5.0;
double r187636 = pow(r187631, r187635);
double r187637 = 0.3333333333333333;
double r187638 = r187637 * r187631;
double r187639 = fma(r187634, r187636, r187638);
double r187640 = fma(r187630, r187633, r187639);
return r187640;
}




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