\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, \frac{x}{\frac{1}{\mathsf{fma}\left(\frac{1}{45} \cdot x, x, \frac{1}{3}\right)}}\right)double f(double x) {
double r2593887 = 1.0;
double r2593888 = x;
double r2593889 = r2593887 / r2593888;
double r2593890 = tan(r2593888);
double r2593891 = r2593887 / r2593890;
double r2593892 = r2593889 - r2593891;
return r2593892;
}
double f(double x) {
double r2593893 = x;
double r2593894 = 5.0;
double r2593895 = pow(r2593893, r2593894);
double r2593896 = 0.0021164021164021165;
double r2593897 = 1.0;
double r2593898 = 0.022222222222222223;
double r2593899 = r2593898 * r2593893;
double r2593900 = 0.3333333333333333;
double r2593901 = fma(r2593899, r2593893, r2593900);
double r2593902 = r2593897 / r2593901;
double r2593903 = r2593893 / r2593902;
double r2593904 = fma(r2593895, r2593896, r2593903);
return r2593904;
}




Bits error versus x
| 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 +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))))