\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\mathsf{fma}\left(x, x, x\right)}}{x - 1}double f(double x) {
double r4574049 = 1.0;
double r4574050 = x;
double r4574051 = r4574050 + r4574049;
double r4574052 = r4574049 / r4574051;
double r4574053 = 2.0;
double r4574054 = r4574053 / r4574050;
double r4574055 = r4574052 - r4574054;
double r4574056 = r4574050 - r4574049;
double r4574057 = r4574049 / r4574056;
double r4574058 = r4574055 + r4574057;
return r4574058;
}
double f(double x) {
double r4574059 = 2.0;
double r4574060 = x;
double r4574061 = fma(r4574060, r4574060, r4574060);
double r4574062 = r4574059 / r4574061;
double r4574063 = 1.0;
double r4574064 = r4574060 - r4574063;
double r4574065 = r4574062 / r4574064;
return r4574065;
}




Bits error versus x
| Original | 9.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.7
rmApplied frac-sub26.3
Applied frac-add25.6
Simplified25.9
Simplified25.9
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019163 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))