\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 r2226173 = 1.0;
double r2226174 = x;
double r2226175 = r2226174 + r2226173;
double r2226176 = r2226173 / r2226175;
double r2226177 = 2.0;
double r2226178 = r2226177 / r2226174;
double r2226179 = r2226176 - r2226178;
double r2226180 = r2226174 - r2226173;
double r2226181 = r2226173 / r2226180;
double r2226182 = r2226179 + r2226181;
return r2226182;
}
double f(double x) {
double r2226183 = 2.0;
double r2226184 = x;
double r2226185 = 1.0;
double r2226186 = r2226184 + r2226185;
double r2226187 = r2226183 / r2226186;
double r2226188 = r2226187 / r2226184;
double r2226189 = r2226184 - r2226185;
double r2226190 = r2226188 / r2226189;
return r2226190;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
rmApplied frac-sub26.2
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 2019152
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))