\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.333333333333333315, x, \mathsf{fma}\left(0.0222222222222222231, {x}^{3}, 0.00211640211640211654 \cdot {x}^{5}\right)\right)double f(double x) {
double r43087 = 1.0;
double r43088 = x;
double r43089 = r43087 / r43088;
double r43090 = tan(r43088);
double r43091 = r43087 / r43090;
double r43092 = r43089 - r43091;
return r43092;
}
double f(double x) {
double r43093 = 0.3333333333333333;
double r43094 = x;
double r43095 = 0.022222222222222223;
double r43096 = 3.0;
double r43097 = pow(r43094, r43096);
double r43098 = 0.0021164021164021165;
double r43099 = 5.0;
double r43100 = pow(r43094, r43099);
double r43101 = r43098 * r43100;
double r43102 = fma(r43095, r43097, r43101);
double r43103 = fma(r43093, r43094, r43102);
return r43103;
}




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