\frac{1}{x} - \frac{1}{\tan x}(\left({x}^{5}\right) \cdot \frac{2}{945} + \left(x \cdot \frac{1}{3} + x \cdot \left(\left(\frac{1}{45} \cdot x\right) \cdot x\right)\right))_*double f(double x) {
double r5597926 = 1.0;
double r5597927 = x;
double r5597928 = r5597926 / r5597927;
double r5597929 = tan(r5597927);
double r5597930 = r5597926 / r5597929;
double r5597931 = r5597928 - r5597930;
return r5597931;
}
double f(double x) {
double r5597932 = x;
double r5597933 = 5.0;
double r5597934 = pow(r5597932, r5597933);
double r5597935 = 0.0021164021164021165;
double r5597936 = 0.3333333333333333;
double r5597937 = r5597932 * r5597936;
double r5597938 = 0.022222222222222223;
double r5597939 = r5597938 * r5597932;
double r5597940 = r5597939 * r5597932;
double r5597941 = r5597932 * r5597940;
double r5597942 = r5597937 + r5597941;
double r5597943 = fma(r5597934, r5597935, r5597942);
return r5597943;
}




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 fma-udef0.3
Applied distribute-lft-in0.3
Final simplification0.3
herbie shell --seed 2019104 +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) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))
(- (/ 1 x) (/ 1 (tan x))))