\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 r146550 = 1.0;
double r146551 = x;
double r146552 = r146550 / r146551;
double r146553 = tan(r146551);
double r146554 = r146550 / r146553;
double r146555 = r146552 - r146554;
return r146555;
}
double f(double x) {
double r146556 = 0.022222222222222223;
double r146557 = x;
double r146558 = 3.0;
double r146559 = pow(r146557, r146558);
double r146560 = 0.0021164021164021165;
double r146561 = 5.0;
double r146562 = pow(r146557, r146561);
double r146563 = 0.3333333333333333;
double r146564 = r146563 * r146557;
double r146565 = fma(r146560, r146562, r146564);
double r146566 = fma(r146556, r146559, r146565);
return r146566;
}




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