\frac{1}{x} - \frac{1}{\tan x}\mathsf{fma}\left(0.02222222222222222307030925492199457949027, {x}^{3}, \mathsf{fma}\left(0.002116402116402116544841005563171165704262, {x}^{5}, 0.3333333333333333148296162562473909929395 \cdot x\right)\right)double f(double x) {
double r96149 = 1.0;
double r96150 = x;
double r96151 = r96149 / r96150;
double r96152 = tan(r96150);
double r96153 = r96149 / r96152;
double r96154 = r96151 - r96153;
return r96154;
}
double f(double x) {
double r96155 = 0.022222222222222223;
double r96156 = x;
double r96157 = 3.0;
double r96158 = pow(r96156, r96157);
double r96159 = 0.0021164021164021165;
double r96160 = 5.0;
double r96161 = pow(r96156, r96160);
double r96162 = 0.3333333333333333;
double r96163 = r96162 * r96156;
double r96164 = fma(r96159, r96161, r96163);
double r96165 = fma(r96155, r96158, r96164);
return r96165;
}




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
Final simplification0.3
herbie shell --seed 2020001 +o rules:numerics
(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) (+ 1 (/ (* x x) 15))) (- (/ 1 x) (/ 1 (tan x))))
(- (/ 1 x) (/ 1 (tan x))))