\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 r2641701 = 1.0;
double r2641702 = x;
double r2641703 = r2641701 / r2641702;
double r2641704 = tan(r2641702);
double r2641705 = r2641701 / r2641704;
double r2641706 = r2641703 - r2641705;
return r2641706;
}
double f(double x) {
double r2641707 = x;
double r2641708 = r2641707 * r2641707;
double r2641709 = 0.022222222222222223;
double r2641710 = 0.3333333333333333;
double r2641711 = fma(r2641708, r2641709, r2641710);
double r2641712 = 0.0021164021164021165;
double r2641713 = 5.0;
double r2641714 = pow(r2641707, r2641713);
double r2641715 = r2641712 * r2641714;
double r2641716 = fma(r2641707, r2641711, r2641715);
return r2641716;
}




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