\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{-1}{\left(x + 1\right) \cdot x} \cdot \frac{2}{1 - x}double f(double x) {
double r124765 = 1.0;
double r124766 = x;
double r124767 = r124766 + r124765;
double r124768 = r124765 / r124767;
double r124769 = 2.0;
double r124770 = r124769 / r124766;
double r124771 = r124768 - r124770;
double r124772 = r124766 - r124765;
double r124773 = r124765 / r124772;
double r124774 = r124771 + r124773;
return r124774;
}
double f(double x) {
double r124775 = -1.0;
double r124776 = x;
double r124777 = 1.0;
double r124778 = r124776 + r124777;
double r124779 = r124778 * r124776;
double r124780 = r124775 / r124779;
double r124781 = 2.0;
double r124782 = r124777 - r124776;
double r124783 = r124781 / r124782;
double r124784 = r124780 * r124783;
return r124784;
}




Bits error versus x
Results
| Original | 10.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 10.2
rmApplied frac-2neg10.2
Simplified10.2
rmApplied frac-sub26.4
Applied frac-add25.8
Simplified25.8
Taylor expanded around 0 0.3
rmApplied neg-mul-10.3
Applied times-frac0.1
Final simplification0.1
herbie shell --seed 2020043
(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))))