\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 r113631 = 1.0;
double r113632 = x;
double r113633 = r113631 / r113632;
double r113634 = tan(r113632);
double r113635 = r113631 / r113634;
double r113636 = r113633 - r113635;
return r113636;
}
double f(double x) {
double r113637 = 0.022222222222222223;
double r113638 = x;
double r113639 = 3.0;
double r113640 = pow(r113638, r113639);
double r113641 = 0.0021164021164021165;
double r113642 = 5.0;
double r113643 = pow(r113638, r113642);
double r113644 = 0.3333333333333333;
double r113645 = r113644 * r113638;
double r113646 = fma(r113641, r113643, r113645);
double r113647 = fma(r113637, r113640, r113646);
return r113647;
}




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