\frac{1}{x} - \frac{1}{\tan x}\frac{1 \cdot \left(0.66666666666666663 \cdot 0.66666666666666663 - \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right) \cdot \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}{\left(\frac{1}{x} + \frac{1}{\tan x}\right) \cdot \left(0.66666666666666663 + \left(x \cdot \left(x \cdot 0.0666666666666666657\right) + {x}^{4} \cdot 0.01058201058201058\right)\right)}double code(double x) {
return ((double) (((double) (1.0 / x)) - ((double) (1.0 / ((double) tan(x))))));
}
double code(double x) {
return ((double) (((double) (1.0 * ((double) (((double) (0.6666666666666666 * 0.6666666666666666)) - ((double) (((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581)))) * ((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581)))))))))) / ((double) (((double) (((double) (1.0 / x)) + ((double) (1.0 / ((double) tan(x)))))) * ((double) (0.6666666666666666 + ((double) (((double) (x * ((double) (x * 0.06666666666666667)))) + ((double) (((double) pow(x, 4.0)) * 0.010582010582010581))))))))));
}




Bits error versus x
Results
| Original | 59.8 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
Initial program 59.8
rmApplied flip--62.1
Simplified62.1
Taylor expanded around 0 0.4
Simplified0.4
rmApplied flip--0.4
Applied associate-*r/0.4
Applied associate-/l/0.4
Final simplification0.4
herbie shell --seed 2020184
(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.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))
(- (/ 1.0 x) (/ 1.0 (tan x))))