\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 r3382554 = 1.0;
double r3382555 = x;
double r3382556 = r3382555 + r3382554;
double r3382557 = r3382554 / r3382556;
double r3382558 = 2.0;
double r3382559 = r3382558 / r3382555;
double r3382560 = r3382557 - r3382559;
double r3382561 = r3382555 - r3382554;
double r3382562 = r3382554 / r3382561;
double r3382563 = r3382560 + r3382562;
return r3382563;
}
double f(double x) {
double r3382564 = 2.0;
double r3382565 = x;
double r3382566 = fma(r3382565, r3382565, r3382565);
double r3382567 = r3382564 / r3382566;
double r3382568 = 1.0;
double r3382569 = r3382565 - r3382568;
double r3382570 = r3382567 / r3382569;
return r3382570;
}




Bits error versus x
| Original | 10.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 10.1
rmApplied frac-sub26.5
rmApplied frac-add25.8
Taylor expanded around inf 0.3
rmApplied associate-/r*0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019143 +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))))