\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 r73860 = 1.0;
double r73861 = x;
double r73862 = r73860 / r73861;
double r73863 = tan(r73861);
double r73864 = r73860 / r73863;
double r73865 = r73862 - r73864;
return r73865;
}
double f(double x) {
double r73866 = 0.022222222222222223;
double r73867 = x;
double r73868 = 3.0;
double r73869 = pow(r73867, r73868);
double r73870 = 0.0021164021164021165;
double r73871 = 5.0;
double r73872 = pow(r73867, r73871);
double r73873 = 0.3333333333333333;
double r73874 = r73873 * r73867;
double r73875 = fma(r73870, r73872, r73874);
double r73876 = fma(r73866, r73869, r73875);
return r73876;
}




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