\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{(x \cdot x + -1)_*}}{x}double f(double x) {
double r21787451 = 1.0;
double r21787452 = x;
double r21787453 = r21787452 + r21787451;
double r21787454 = r21787451 / r21787453;
double r21787455 = 2.0;
double r21787456 = r21787455 / r21787452;
double r21787457 = r21787454 - r21787456;
double r21787458 = r21787452 - r21787451;
double r21787459 = r21787451 / r21787458;
double r21787460 = r21787457 + r21787459;
return r21787460;
}
double f(double x) {
double r21787461 = 2.0;
double r21787462 = x;
double r21787463 = -1.0;
double r21787464 = fma(r21787462, r21787462, r21787463);
double r21787465 = r21787461 / r21787464;
double r21787466 = r21787465 / r21787462;
return r21787466;
}




Bits error versus x
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.8
rmApplied frac-sub25.8
Applied frac-add25.0
Simplified25.4
Simplified25.4
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019112 +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))))