\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, \frac{x}{\frac{1}{\mathsf{fma}\left(x \cdot x, \frac{1}{45}, \frac{1}{3}\right)}}\right)double f(double x) {
double r3000615 = 1.0;
double r3000616 = x;
double r3000617 = r3000615 / r3000616;
double r3000618 = tan(r3000616);
double r3000619 = r3000615 / r3000618;
double r3000620 = r3000617 - r3000619;
return r3000620;
}
double f(double x) {
double r3000621 = x;
double r3000622 = 5.0;
double r3000623 = pow(r3000621, r3000622);
double r3000624 = 0.0021164021164021165;
double r3000625 = 1.0;
double r3000626 = r3000621 * r3000621;
double r3000627 = 0.022222222222222223;
double r3000628 = 0.3333333333333333;
double r3000629 = fma(r3000626, r3000627, r3000628);
double r3000630 = r3000625 / r3000629;
double r3000631 = r3000621 / r3000630;
double r3000632 = fma(r3000623, r3000624, r3000631);
return r3000632;
}




Bits error versus x
| Original | 60.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 60.0
Taylor expanded around 0 0.3
Simplified0.3
rmApplied flip-+0.3
Applied associate-*r/0.3
rmApplied associate-/l*0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2019149 +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))))