\frac{1}{x} - \frac{1}{\tan x}\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(0.02222222222222222307030925492199457949027, {x}^{3}, \mathsf{fma}\left(0.3333333333333333148296162562473909929395, x, 0.002116402116402116544841005563171165704262 \cdot {x}^{5}\right)\right)\right)\right)double f(double x) {
double r130621 = 1.0;
double r130622 = x;
double r130623 = r130621 / r130622;
double r130624 = tan(r130622);
double r130625 = r130621 / r130624;
double r130626 = r130623 - r130625;
return r130626;
}
double f(double x) {
double r130627 = 0.022222222222222223;
double r130628 = x;
double r130629 = 3.0;
double r130630 = pow(r130628, r130629);
double r130631 = 0.3333333333333333;
double r130632 = 0.0021164021164021165;
double r130633 = 5.0;
double r130634 = pow(r130628, r130633);
double r130635 = r130632 * r130634;
double r130636 = fma(r130631, r130628, r130635);
double r130637 = fma(r130627, r130630, r130636);
double r130638 = log1p(r130637);
double r130639 = expm1(r130638);
return r130639;
}




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
rmApplied expm1-log1p-u0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019195 +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))))