\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{x - 1}}{\left(x + 1\right) \cdot x}double f(double x) {
double r140979 = 1.0;
double r140980 = x;
double r140981 = r140980 + r140979;
double r140982 = r140979 / r140981;
double r140983 = 2.0;
double r140984 = r140983 / r140980;
double r140985 = r140982 - r140984;
double r140986 = r140980 - r140979;
double r140987 = r140979 / r140986;
double r140988 = r140985 + r140987;
return r140988;
}
double f(double x) {
double r140989 = 2.0;
double r140990 = x;
double r140991 = 1.0;
double r140992 = r140990 - r140991;
double r140993 = r140989 / r140992;
double r140994 = r140990 + r140991;
double r140995 = r140994 * r140990;
double r140996 = r140993 / r140995;
return r140996;
}




Bits error versus x
Results
| Original | 9.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.7
rmApplied frac-sub25.5
Applied frac-add25.0
Taylor expanded around 0 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
rmApplied pow10.1
Applied pow10.1
Applied pow-prod-down0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2020035
(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))))