\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.002116402116402116544841005563171165704262, {x}^{5}, x \cdot \mathsf{fma}\left(0.02222222222222222307030925492199457949027, x \cdot x, 0.3333333333333333148296162562473909929395\right)\right)double f(double x) {
double r4418080 = 1.0;
double r4418081 = x;
double r4418082 = r4418080 / r4418081;
double r4418083 = tan(r4418081);
double r4418084 = r4418080 / r4418083;
double r4418085 = r4418082 - r4418084;
return r4418085;
}
double f(double x) {
double r4418086 = 0.0021164021164021165;
double r4418087 = x;
double r4418088 = 5.0;
double r4418089 = pow(r4418087, r4418088);
double r4418090 = 0.022222222222222223;
double r4418091 = r4418087 * r4418087;
double r4418092 = 0.3333333333333333;
double r4418093 = fma(r4418090, r4418091, r4418092);
double r4418094 = r4418087 * r4418093;
double r4418095 = fma(r4418086, r4418089, r4418094);
return r4418095;
}




Bits error versus x
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
Initial program 59.9
Taylor expanded around 0 0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2019169 +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.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))
(- (/ 1.0 x) (/ 1.0 (tan x))))