\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\left(x - 1\right) \cdot x}}{x + 1}double f(double x) {
double r138045 = 1.0;
double r138046 = x;
double r138047 = r138046 + r138045;
double r138048 = r138045 / r138047;
double r138049 = 2.0;
double r138050 = r138049 / r138046;
double r138051 = r138048 - r138050;
double r138052 = r138046 - r138045;
double r138053 = r138045 / r138052;
double r138054 = r138051 + r138053;
return r138054;
}
double f(double x) {
double r138055 = 2.0;
double r138056 = x;
double r138057 = 1.0;
double r138058 = r138056 - r138057;
double r138059 = r138058 * r138056;
double r138060 = r138055 / r138059;
double r138061 = r138056 + r138057;
double r138062 = r138060 / r138061;
return r138062;
}




Bits error versus x
Results
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.8
Simplified9.8
rmApplied add-cube-cbrt24.4
Applied add-cube-cbrt24.4
Applied times-frac25.1
rmApplied frac-times24.4
Applied frac-sub28.6
Applied frac-sub25.8
Simplified25.5
Simplified25.5
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2019208
(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))))