\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(x, \mathsf{fma}\left(x \cdot x, \frac{1}{45}, \frac{1}{3}\right), \frac{2}{945} \cdot {x}^{5}\right)double f(double x) {
double r4432976 = 1.0;
double r4432977 = x;
double r4432978 = r4432976 / r4432977;
double r4432979 = tan(r4432977);
double r4432980 = r4432976 / r4432979;
double r4432981 = r4432978 - r4432980;
return r4432981;
}
double f(double x) {
double r4432982 = x;
double r4432983 = r4432982 * r4432982;
double r4432984 = 0.022222222222222223;
double r4432985 = 0.3333333333333333;
double r4432986 = fma(r4432983, r4432984, r4432985);
double r4432987 = 0.0021164021164021165;
double r4432988 = 5.0;
double r4432989 = pow(r4432982, r4432988);
double r4432990 = r4432987 * r4432989;
double r4432991 = fma(r4432982, r4432986, r4432990);
return r4432991;
}




Bits error versus x
| Original | 60.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 60.0
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019163 +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))))