\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 r92508 = 1.0;
double r92509 = x;
double r92510 = r92508 / r92509;
double r92511 = tan(r92509);
double r92512 = r92508 / r92511;
double r92513 = r92510 - r92512;
return r92513;
}
double f(double x) {
double r92514 = 0.022222222222222223;
double r92515 = x;
double r92516 = 3.0;
double r92517 = pow(r92515, r92516);
double r92518 = 0.0021164021164021165;
double r92519 = 5.0;
double r92520 = pow(r92515, r92519);
double r92521 = 0.3333333333333333;
double r92522 = r92521 * r92515;
double r92523 = fma(r92518, r92520, r92522);
double r92524 = fma(r92514, r92517, r92523);
return r92524;
}




Bits error versus x
| Original | 59.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
Initial program 59.9
Taylor expanded around 0 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2020064 +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))))