\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, \mathsf{fma}\left(\frac{1}{45}, x \cdot x, \frac{1}{3}\right) \cdot x\right)double f(double x) {
double r2788331 = 1.0;
double r2788332 = x;
double r2788333 = r2788331 / r2788332;
double r2788334 = tan(r2788332);
double r2788335 = r2788331 / r2788334;
double r2788336 = r2788333 - r2788335;
return r2788336;
}
double f(double x) {
double r2788337 = x;
double r2788338 = 5.0;
double r2788339 = pow(r2788337, r2788338);
double r2788340 = 0.0021164021164021165;
double r2788341 = 0.022222222222222223;
double r2788342 = r2788337 * r2788337;
double r2788343 = 0.3333333333333333;
double r2788344 = fma(r2788341, r2788342, r2788343);
double r2788345 = r2788344 * r2788337;
double r2788346 = fma(r2788339, r2788340, r2788345);
return r2788346;
}




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