\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 r1835132 = 1.0;
double r1835133 = x;
double r1835134 = r1835132 / r1835133;
double r1835135 = tan(r1835133);
double r1835136 = r1835132 / r1835135;
double r1835137 = r1835134 - r1835136;
return r1835137;
}
double f(double x) {
double r1835138 = x;
double r1835139 = 5.0;
double r1835140 = pow(r1835138, r1835139);
double r1835141 = 0.0021164021164021165;
double r1835142 = 0.022222222222222223;
double r1835143 = r1835138 * r1835138;
double r1835144 = 0.3333333333333333;
double r1835145 = fma(r1835142, r1835143, r1835144);
double r1835146 = r1835145 * r1835138;
double r1835147 = fma(r1835140, r1835141, r1835146);
return r1835147;
}




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