\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 r117093 = 1.0;
double r117094 = x;
double r117095 = r117094 + r117093;
double r117096 = r117093 / r117095;
double r117097 = 2.0;
double r117098 = r117097 / r117094;
double r117099 = r117096 - r117098;
double r117100 = r117094 - r117093;
double r117101 = r117093 / r117100;
double r117102 = r117099 + r117101;
return r117102;
}
double f(double x) {
double r117103 = 2.0;
double r117104 = x;
double r117105 = 1.0;
double r117106 = r117104 + r117105;
double r117107 = r117106 * r117104;
double r117108 = r117103 / r117107;
double r117109 = r117104 - r117105;
double r117110 = r117108 / r117109;
return r117110;
}




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