\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 r79880 = 1.0;
double r79881 = x;
double r79882 = r79881 + r79880;
double r79883 = r79880 / r79882;
double r79884 = 2.0;
double r79885 = r79884 / r79881;
double r79886 = r79883 - r79885;
double r79887 = r79881 - r79880;
double r79888 = r79880 / r79887;
double r79889 = r79886 + r79888;
return r79889;
}
double f(double x) {
double r79890 = 2.0;
double r79891 = x;
double r79892 = 1.0;
double r79893 = r79891 + r79892;
double r79894 = r79890 / r79893;
double r79895 = r79894 / r79891;
double r79896 = r79891 - r79892;
double r79897 = r79895 / r79896;
return r79897;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
rmApplied frac-sub26.1
Applied frac-add25.8
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019323
(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))))