\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 r111567 = 1.0;
double r111568 = x;
double r111569 = r111568 + r111567;
double r111570 = r111567 / r111569;
double r111571 = 2.0;
double r111572 = r111571 / r111568;
double r111573 = r111570 - r111572;
double r111574 = r111568 - r111567;
double r111575 = r111567 / r111574;
double r111576 = r111573 + r111575;
return r111576;
}
double f(double x) {
double r111577 = 2.0;
double r111578 = x;
double r111579 = 1.0;
double r111580 = r111578 + r111579;
double r111581 = r111580 * r111578;
double r111582 = r111577 / r111581;
double r111583 = r111578 - r111579;
double r111584 = r111582 / r111583;
return r111584;
}




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