\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{x}}{x \cdot x - 1}double f(double x) {
double r101521 = 1.0;
double r101522 = x;
double r101523 = r101522 + r101521;
double r101524 = r101521 / r101523;
double r101525 = 2.0;
double r101526 = r101525 / r101522;
double r101527 = r101524 - r101526;
double r101528 = r101522 - r101521;
double r101529 = r101521 / r101528;
double r101530 = r101527 + r101529;
return r101530;
}
double f(double x) {
double r101531 = 2.0;
double r101532 = x;
double r101533 = r101531 / r101532;
double r101534 = r101532 * r101532;
double r101535 = 1.0;
double r101536 = r101534 - r101535;
double r101537 = r101533 / r101536;
return r101537;
}




Bits error versus x
Results
| Original | 9.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 9.6
rmApplied frac-sub25.5
Applied frac-add25.1
Simplified25.5
Taylor expanded around 0 0.3
Taylor expanded around 0 0.2
rmApplied unpow30.2
Applied distribute-rgt-out--0.2
Applied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019306 +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))))