\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, x \cdot \frac{1}{3} + x \cdot \left(\frac{1}{45} \cdot \left(x \cdot x\right)\right)\right)double f(double x) {
double r1416595 = 1.0;
double r1416596 = x;
double r1416597 = r1416595 / r1416596;
double r1416598 = tan(r1416596);
double r1416599 = r1416595 / r1416598;
double r1416600 = r1416597 - r1416599;
return r1416600;
}
double f(double x) {
double r1416601 = x;
double r1416602 = 5.0;
double r1416603 = pow(r1416601, r1416602);
double r1416604 = 0.0021164021164021165;
double r1416605 = 0.3333333333333333;
double r1416606 = r1416601 * r1416605;
double r1416607 = 0.022222222222222223;
double r1416608 = r1416601 * r1416601;
double r1416609 = r1416607 * r1416608;
double r1416610 = r1416601 * r1416609;
double r1416611 = r1416606 + r1416610;
double r1416612 = fma(r1416603, r1416604, r1416611);
return r1416612;
}




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
rmApplied fma-udef0.3
Applied distribute-rgt-in0.3
Final simplification0.3
herbie shell --seed 2019158 +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))))