\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left({x}^{5}, \frac{2}{945}, \frac{x}{\mathsf{fma}\left(x \cdot x, \frac{-1}{5}, \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{75}, 3\right)\right)}\right)double f(double x) {
double r2376052 = 1.0;
double r2376053 = x;
double r2376054 = r2376052 / r2376053;
double r2376055 = tan(r2376053);
double r2376056 = r2376052 / r2376055;
double r2376057 = r2376054 - r2376056;
return r2376057;
}
double f(double x) {
double r2376058 = x;
double r2376059 = 5.0;
double r2376060 = pow(r2376058, r2376059);
double r2376061 = 0.0021164021164021165;
double r2376062 = r2376058 * r2376058;
double r2376063 = -0.2;
double r2376064 = r2376062 * r2376062;
double r2376065 = 0.013333333333333334;
double r2376066 = 3.0;
double r2376067 = fma(r2376064, r2376065, r2376066);
double r2376068 = fma(r2376062, r2376063, r2376067);
double r2376069 = r2376058 / r2376068;
double r2376070 = fma(r2376060, r2376061, r2376069);
return r2376070;
}




Bits error versus x
| Original | 59.8 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
Initial program 59.8
Taylor expanded around 0 0.3
Simplified0.3
rmApplied flip-+0.3
Applied associate-*r/0.3
rmApplied associate-/l*0.0
Simplified0.0
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2019138 +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))))