\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 r214201 = 1.0;
double r214202 = x;
double r214203 = r214202 + r214201;
double r214204 = r214201 / r214203;
double r214205 = 2.0;
double r214206 = r214205 / r214202;
double r214207 = r214204 - r214206;
double r214208 = r214202 - r214201;
double r214209 = r214201 / r214208;
double r214210 = r214207 + r214209;
return r214210;
}
double f(double x) {
double r214211 = 2.0;
double r214212 = x;
double r214213 = 1.0;
double r214214 = r214212 + r214213;
double r214215 = r214214 * r214212;
double r214216 = r214211 / r214215;
double r214217 = r214212 - r214213;
double r214218 = r214216 / r214217;
return r214218;
}




Bits error versus x
Results
| Original | 10.0 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
Initial program 10.0
rmApplied frac-sub26.2
Applied frac-add25.8
Simplified26.2
Taylor expanded around 0 0.4
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019354 +o rules:numerics
(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))))