\frac{1}{x} - \frac{1}{\tan x}\frac{x}{\frac{1}{\frac{1}{3} + \frac{1}{45} \cdot \left(x \cdot x\right)}} + {x}^{5} \cdot \frac{2}{945}double f(double x) {
double r2593731 = 1.0;
double r2593732 = x;
double r2593733 = r2593731 / r2593732;
double r2593734 = tan(r2593732);
double r2593735 = r2593731 / r2593734;
double r2593736 = r2593733 - r2593735;
return r2593736;
}
double f(double x) {
double r2593737 = x;
double r2593738 = 1.0;
double r2593739 = 0.3333333333333333;
double r2593740 = 0.022222222222222223;
double r2593741 = r2593737 * r2593737;
double r2593742 = r2593740 * r2593741;
double r2593743 = r2593739 + r2593742;
double r2593744 = r2593738 / r2593743;
double r2593745 = r2593737 / r2593744;
double r2593746 = 5.0;
double r2593747 = pow(r2593737, r2593746);
double r2593748 = 0.0021164021164021165;
double r2593749 = r2593747 * r2593748;
double r2593750 = r2593745 + r2593749;
return r2593750;
}




Bits error versus x
Results
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 59.9
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 2019146
(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))))