\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 r4804238 = 1.0;
double r4804239 = x;
double r4804240 = r4804239 + r4804238;
double r4804241 = r4804238 / r4804240;
double r4804242 = 2.0;
double r4804243 = r4804242 / r4804239;
double r4804244 = r4804241 - r4804243;
double r4804245 = r4804239 - r4804238;
double r4804246 = r4804238 / r4804245;
double r4804247 = r4804244 + r4804246;
return r4804247;
}
double f(double x) {
double r4804248 = 2.0;
double r4804249 = x;
double r4804250 = 1.0;
double r4804251 = r4804249 + r4804250;
double r4804252 = r4804251 * r4804249;
double r4804253 = r4804248 / r4804252;
double r4804254 = r4804249 - r4804250;
double r4804255 = r4804253 / r4804254;
return r4804255;
}




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