\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 r106135 = 1.0;
double r106136 = x;
double r106137 = r106135 / r106136;
double r106138 = tan(r106136);
double r106139 = r106135 / r106138;
double r106140 = r106137 - r106139;
return r106140;
}
double f(double x) {
double r106141 = 0.022222222222222223;
double r106142 = x;
double r106143 = 3.0;
double r106144 = pow(r106142, r106143);
double r106145 = 0.0021164021164021165;
double r106146 = 5.0;
double r106147 = pow(r106142, r106146);
double r106148 = 0.3333333333333333;
double r106149 = r106148 * r106142;
double r106150 = fma(r106145, r106147, r106149);
double r106151 = fma(r106141, r106144, r106150);
return r106151;
}




Bits error versus x
| Original | 59.8 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
Initial program 59.8
Taylor expanded around 0 0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020057 +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))))