\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{\frac{2}{x - 1}}{1 + x}}{x}double f(double x) {
double r4416244 = 1.0;
double r4416245 = x;
double r4416246 = r4416245 + r4416244;
double r4416247 = r4416244 / r4416246;
double r4416248 = 2.0;
double r4416249 = r4416248 / r4416245;
double r4416250 = r4416247 - r4416249;
double r4416251 = r4416245 - r4416244;
double r4416252 = r4416244 / r4416251;
double r4416253 = r4416250 + r4416252;
return r4416253;
}
double f(double x) {
double r4416254 = 2.0;
double r4416255 = x;
double r4416256 = 1.0;
double r4416257 = r4416255 - r4416256;
double r4416258 = r4416254 / r4416257;
double r4416259 = r4416256 + r4416255;
double r4416260 = r4416258 / r4416259;
double r4416261 = r4416260 / r4416255;
return r4416261;
}




Bits error versus x
Results
| Original | 9.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 9.7
rmApplied frac-sub26.2
Applied frac-add25.7
Taylor expanded around 0 0.2
rmApplied *-un-lft-identity0.2
Applied times-frac0.1
rmApplied *-un-lft-identity0.1
Applied associate-*l*0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019171
(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))))