\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 r4605663 = 1.0;
double r4605664 = x;
double r4605665 = r4605663 / r4605664;
double r4605666 = tan(r4605664);
double r4605667 = r4605663 / r4605666;
double r4605668 = r4605665 - r4605667;
return r4605668;
}
double f(double x) {
double r4605669 = x;
double r4605670 = r4605669 * r4605669;
double r4605671 = 0.022222222222222223;
double r4605672 = 0.3333333333333333;
double r4605673 = fma(r4605670, r4605671, r4605672);
double r4605674 = 0.0021164021164021165;
double r4605675 = 5.0;
double r4605676 = pow(r4605669, r4605675);
double r4605677 = r4605674 * r4605676;
double r4605678 = fma(r4605669, r4605673, r4605677);
return r4605678;
}




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