double f(double x) {
double r12123371 = 1.0;
double r12123372 = x;
double r12123373 = r12123372 + r12123371;
double r12123374 = r12123371 / r12123373;
double r12123375 = 2.0;
double r12123376 = r12123375 / r12123372;
double r12123377 = r12123374 - r12123376;
double r12123378 = r12123372 - r12123371;
double r12123379 = r12123371 / r12123378;
double r12123380 = r12123377 + r12123379;
return r12123380;
}
double f(double x) {
double r12123381 = 2.0;
double r12123382 = x;
double r12123383 = -1.0;
double r12123384 = fma(r12123382, r12123382, r12123383);
double r12123385 = r12123381 / r12123384;
double r12123386 = r12123385 / r12123382;
return r12123386;
}
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{(x \cdot x + -1)_*}}{x}



Bits error versus x
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
rmApplied frac-sub26.0
Applied frac-add25.4
Simplified25.7
Simplified25.7
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019102 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))