\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.0222222222222222231, {x}^{3}, \mathsf{fma}\left(0.00211640211640211654, {x}^{5}, 0.333333333333333315 \cdot x\right)\right)double f(double x) {
double r123063 = 1.0;
double r123064 = x;
double r123065 = r123063 / r123064;
double r123066 = tan(r123064);
double r123067 = r123063 / r123066;
double r123068 = r123065 - r123067;
return r123068;
}
double f(double x) {
double r123069 = 0.022222222222222223;
double r123070 = x;
double r123071 = 3.0;
double r123072 = pow(r123070, r123071);
double r123073 = 0.0021164021164021165;
double r123074 = 5.0;
double r123075 = pow(r123070, r123074);
double r123076 = 0.3333333333333333;
double r123077 = r123076 * r123070;
double r123078 = fma(r123073, r123075, r123077);
double r123079 = fma(r123069, r123072, r123078);
return r123079;
}




Bits error versus x
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 59.9
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2020035 +o rules:numerics
(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))))