\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\mathsf{fma}\left(x, x, x\right)}}{x - 1}double f(double x) {
double r4461692 = 1.0;
double r4461693 = x;
double r4461694 = r4461693 + r4461692;
double r4461695 = r4461692 / r4461694;
double r4461696 = 2.0;
double r4461697 = r4461696 / r4461693;
double r4461698 = r4461695 - r4461697;
double r4461699 = r4461693 - r4461692;
double r4461700 = r4461692 / r4461699;
double r4461701 = r4461698 + r4461700;
return r4461701;
}
double f(double x) {
double r4461702 = 2.0;
double r4461703 = x;
double r4461704 = fma(r4461703, r4461703, r4461703);
double r4461705 = r4461702 / r4461704;
double r4461706 = 1.0;
double r4461707 = r4461703 - r4461706;
double r4461708 = r4461705 / r4461707;
return r4461708;
}




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