\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 r4039826 = 1.0;
double r4039827 = x;
double r4039828 = r4039827 + r4039826;
double r4039829 = r4039826 / r4039828;
double r4039830 = 2.0;
double r4039831 = r4039830 / r4039827;
double r4039832 = r4039829 - r4039831;
double r4039833 = r4039827 - r4039826;
double r4039834 = r4039826 / r4039833;
double r4039835 = r4039832 + r4039834;
return r4039835;
}
double f(double x) {
double r4039836 = 2.0;
double r4039837 = x;
double r4039838 = 1.0;
double r4039839 = r4039837 + r4039838;
double r4039840 = r4039839 * r4039837;
double r4039841 = r4039836 / r4039840;
double r4039842 = r4039837 - r4039838;
double r4039843 = r4039841 / r4039842;
return r4039843;
}




Bits error versus x
Results
| Original | 9.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 9.5
rmApplied frac-sub25.6
Applied frac-add24.9
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019134
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))