\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 r4337918 = 1.0;
double r4337919 = x;
double r4337920 = r4337919 + r4337918;
double r4337921 = r4337918 / r4337920;
double r4337922 = 2.0;
double r4337923 = r4337922 / r4337919;
double r4337924 = r4337921 - r4337923;
double r4337925 = r4337919 - r4337918;
double r4337926 = r4337918 / r4337925;
double r4337927 = r4337924 + r4337926;
return r4337927;
}
double f(double x) {
double r4337928 = 2.0;
double r4337929 = x;
double r4337930 = 1.0;
double r4337931 = r4337929 + r4337930;
double r4337932 = r4337931 * r4337929;
double r4337933 = r4337928 / r4337932;
double r4337934 = r4337929 - r4337930;
double r4337935 = r4337933 / r4337934;
return r4337935;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
rmApplied frac-sub25.4
Applied frac-add25.0
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019172
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))