\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 r98597 = 1.0;
double r98598 = x;
double r98599 = r98597 / r98598;
double r98600 = tan(r98598);
double r98601 = r98597 / r98600;
double r98602 = r98599 - r98601;
return r98602;
}
double f(double x) {
double r98603 = 0.022222222222222223;
double r98604 = x;
double r98605 = 3.0;
double r98606 = pow(r98604, r98605);
double r98607 = 0.0021164021164021165;
double r98608 = 5.0;
double r98609 = pow(r98604, r98608);
double r98610 = 0.3333333333333333;
double r98611 = r98610 * r98604;
double r98612 = fma(r98607, r98609, r98611);
double r98613 = fma(r98603, r98606, r98612);
return r98613;
}




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 2020047 +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))))