\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, \mathsf{fma}\left(\frac{1}{45}, x \cdot x, \frac{1}{3}\right) \cdot x\right)double f(double x) {
double r2685339 = 1.0;
double r2685340 = x;
double r2685341 = r2685339 / r2685340;
double r2685342 = tan(r2685340);
double r2685343 = r2685339 / r2685342;
double r2685344 = r2685341 - r2685343;
return r2685344;
}
double f(double x) {
double r2685345 = x;
double r2685346 = 5.0;
double r2685347 = pow(r2685345, r2685346);
double r2685348 = 0.0021164021164021165;
double r2685349 = 0.022222222222222223;
double r2685350 = r2685345 * r2685345;
double r2685351 = 0.3333333333333333;
double r2685352 = fma(r2685349, r2685350, r2685351);
double r2685353 = r2685352 * r2685345;
double r2685354 = fma(r2685347, r2685348, r2685353);
return r2685354;
}




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 2019162 +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) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))
(- (/ 1 x) (/ 1 (tan x))))