\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{2}{\left(x + 1\right) \cdot \left(x \cdot \left(x - 1\right)\right)}double f(double x) {
double r3851997 = 1.0;
double r3851998 = x;
double r3851999 = r3851998 + r3851997;
double r3852000 = r3851997 / r3851999;
double r3852001 = 2.0;
double r3852002 = r3852001 / r3851998;
double r3852003 = r3852000 - r3852002;
double r3852004 = r3851998 - r3851997;
double r3852005 = r3851997 / r3852004;
double r3852006 = r3852003 + r3852005;
return r3852006;
}
double f(double x) {
double r3852007 = 2.0;
double r3852008 = x;
double r3852009 = 1.0;
double r3852010 = r3852008 + r3852009;
double r3852011 = r3852008 - r3852009;
double r3852012 = r3852008 * r3852011;
double r3852013 = r3852010 * r3852012;
double r3852014 = r3852007 / r3852013;
return r3852014;
}




Bits error versus x
Results
| Original | 10.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 10.2
rmApplied frac-sub26.1
Applied frac-add25.6
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
rmApplied *-un-lft-identity0.1
Applied flip-+0.1
Applied associate-*l/0.3
Applied associate-/r/0.3
Applied times-frac0.3
Simplified0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019179 +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))))