\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 r117650 = 1.0;
double r117651 = x;
double r117652 = r117651 + r117650;
double r117653 = r117650 / r117652;
double r117654 = 2.0;
double r117655 = r117654 / r117651;
double r117656 = r117653 - r117655;
double r117657 = r117651 - r117650;
double r117658 = r117650 / r117657;
double r117659 = r117656 + r117658;
return r117659;
}
double f(double x) {
double r117660 = 2.0;
double r117661 = x;
double r117662 = 1.0;
double r117663 = r117661 + r117662;
double r117664 = r117660 / r117663;
double r117665 = r117664 / r117661;
double r117666 = r117661 - r117662;
double r117667 = r117665 / r117666;
return r117667;
}




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))))