\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{\frac{2}{x + 1}}{x}}{x - 1}double f(double x) {
double r121304 = 1.0;
double r121305 = x;
double r121306 = r121305 + r121304;
double r121307 = r121304 / r121306;
double r121308 = 2.0;
double r121309 = r121308 / r121305;
double r121310 = r121307 - r121309;
double r121311 = r121305 - r121304;
double r121312 = r121304 / r121311;
double r121313 = r121310 + r121312;
return r121313;
}
double f(double x) {
double r121314 = 2.0;
double r121315 = x;
double r121316 = 1.0;
double r121317 = r121315 + r121316;
double r121318 = r121314 / r121317;
double r121319 = r121318 / r121315;
double r121320 = r121315 - r121316;
double r121321 = r121319 / r121320;
return r121321;
}




Bits error versus x
Results
| Original | 9.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.5
rmApplied frac-sub26.0
Applied frac-add25.5
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2020047
(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))))