\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{\frac{2}{x + 1}}{x}}{x - 1}double f(double x) {
double r120660 = 1.0;
double r120661 = x;
double r120662 = r120661 + r120660;
double r120663 = r120660 / r120662;
double r120664 = 2.0;
double r120665 = r120664 / r120661;
double r120666 = r120663 - r120665;
double r120667 = r120661 - r120660;
double r120668 = r120660 / r120667;
double r120669 = r120666 + r120668;
return r120669;
}
double f(double x) {
double r120670 = 2.0;
double r120671 = x;
double r120672 = 1.0;
double r120673 = r120671 + r120672;
double r120674 = r120670 / r120673;
double r120675 = r120674 / r120671;
double r120676 = r120671 - r120672;
double r120677 = r120675 / r120676;
return r120677;
}




Bits error versus x
Results
| Original | 9.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.5
rmApplied frac-sub26.0
Applied frac-add25.5
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2020047
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))