\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 r139624 = 1.0;
double r139625 = x;
double r139626 = r139625 + r139624;
double r139627 = r139624 / r139626;
double r139628 = 2.0;
double r139629 = r139628 / r139625;
double r139630 = r139627 - r139629;
double r139631 = r139625 - r139624;
double r139632 = r139624 / r139631;
double r139633 = r139630 + r139632;
return r139633;
}
double f(double x) {
double r139634 = 2.0;
double r139635 = x;
double r139636 = 1.0;
double r139637 = r139635 + r139636;
double r139638 = r139637 * r139635;
double r139639 = r139634 / r139638;
double r139640 = r139635 - r139636;
double r139641 = r139639 / r139640;
return r139641;
}




Bits error versus x
Results
| Original | 9.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.7
rmApplied frac-sub26.2
Applied frac-add25.7
Simplified26.1
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2020018 +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))))