\frac{1}{x} - \frac{1}{\tan x}\left(0.0222222222222222231 \cdot {x}^{3} + 0.00211640211640211654 \cdot {x}^{5}\right) + 0.333333333333333315 \cdot xdouble f(double x) {
double r92876 = 1.0;
double r92877 = x;
double r92878 = r92876 / r92877;
double r92879 = tan(r92877);
double r92880 = r92876 / r92879;
double r92881 = r92878 - r92880;
return r92881;
}
double f(double x) {
double r92882 = 0.022222222222222223;
double r92883 = x;
double r92884 = 3.0;
double r92885 = pow(r92883, r92884);
double r92886 = r92882 * r92885;
double r92887 = 0.0021164021164021165;
double r92888 = 5.0;
double r92889 = pow(r92883, r92888);
double r92890 = r92887 * r92889;
double r92891 = r92886 + r92890;
double r92892 = 0.3333333333333333;
double r92893 = r92892 * r92883;
double r92894 = r92891 + r92893;
return r92894;
}




Bits error versus x
Results
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 59.9
Taylor expanded around 0 0.3
rmApplied associate-+r+0.3
Final simplification0.3
herbie shell --seed 2020056
(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))))