\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 r150481 = 1.0;
double r150482 = x;
double r150483 = r150482 + r150481;
double r150484 = r150481 / r150483;
double r150485 = 2.0;
double r150486 = r150485 / r150482;
double r150487 = r150484 - r150486;
double r150488 = r150482 - r150481;
double r150489 = r150481 / r150488;
double r150490 = r150487 + r150489;
return r150490;
}
double f(double x) {
double r150491 = 2.0;
double r150492 = x;
double r150493 = 1.0;
double r150494 = r150492 - r150493;
double r150495 = r150494 * r150492;
double r150496 = r150491 / r150495;
double r150497 = r150492 + r150493;
double r150498 = r150496 / r150497;
return r150498;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
Simplified9.9
rmApplied frac-sub25.7
Applied frac-add25.3
Simplified25.7
Simplified25.7
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019174 +o rules:numerics
(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))))