\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{x \cdot \left(1 + x\right)}}{x - 1}double f(double x) {
double r1632827 = 1.0;
double r1632828 = x;
double r1632829 = r1632828 + r1632827;
double r1632830 = r1632827 / r1632829;
double r1632831 = 2.0;
double r1632832 = r1632831 / r1632828;
double r1632833 = r1632830 - r1632832;
double r1632834 = r1632828 - r1632827;
double r1632835 = r1632827 / r1632834;
double r1632836 = r1632833 + r1632835;
return r1632836;
}
double f(double x) {
double r1632837 = 2.0;
double r1632838 = x;
double r1632839 = 1.0;
double r1632840 = r1632839 + r1632838;
double r1632841 = r1632838 * r1632840;
double r1632842 = r1632837 / r1632841;
double r1632843 = r1632838 - r1632839;
double r1632844 = r1632842 / r1632843;
return r1632844;
}




Bits error versus x
Results
| Original | 10.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 10.2
rmApplied frac-sub26.4
Applied frac-add25.8
Taylor expanded around 0 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
rmApplied associate-*r/0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019153 +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))))