\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{x \cdot x - 1 \cdot 1}}{x}double f(double x) {
double r101446 = 1.0;
double r101447 = x;
double r101448 = r101447 + r101446;
double r101449 = r101446 / r101448;
double r101450 = 2.0;
double r101451 = r101450 / r101447;
double r101452 = r101449 - r101451;
double r101453 = r101447 - r101446;
double r101454 = r101446 / r101453;
double r101455 = r101452 + r101454;
return r101455;
}
double f(double x) {
double r101456 = 2.0;
double r101457 = x;
double r101458 = r101457 * r101457;
double r101459 = 1.0;
double r101460 = r101459 * r101459;
double r101461 = r101458 - r101460;
double r101462 = r101456 / r101461;
double r101463 = r101462 / r101457;
return r101463;
}




Bits error versus x
Results
| Original | 10.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 10.6
rmApplied frac-sub26.2
Applied frac-add25.6
Simplified26.0
Taylor expanded around 0 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
rmApplied pow10.1
Applied pow10.1
Applied pow-prod-down0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2020045 +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))))