\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}double f(double x) {
double r161745 = 1.0;
double r161746 = x;
double r161747 = r161746 + r161745;
double r161748 = r161745 / r161747;
double r161749 = 2.0;
double r161750 = r161749 / r161746;
double r161751 = r161748 - r161750;
double r161752 = r161746 - r161745;
double r161753 = r161745 / r161752;
double r161754 = r161751 + r161753;
return r161754;
}
double f(double x) {
double r161755 = 2.0;
double r161756 = x;
double r161757 = 1.0;
double r161758 = r161756 + r161757;
double r161759 = r161758 * r161756;
double r161760 = r161755 / r161759;
double r161761 = r161756 - r161757;
double r161762 = r161760 / r161761;
return r161762;
}




Bits error versus x
Results
| Original | 9.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 9.8
rmApplied frac-sub26.3
Applied frac-add25.9
Simplified26.3
Taylor expanded around 0 0.2
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2020033 +o rules:numerics
(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))))