\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{x \cdot \left(1 + x\right)}}{x - 1}double f(double x) {
double r1651130 = 1.0;
double r1651131 = x;
double r1651132 = r1651131 + r1651130;
double r1651133 = r1651130 / r1651132;
double r1651134 = 2.0;
double r1651135 = r1651134 / r1651131;
double r1651136 = r1651133 - r1651135;
double r1651137 = r1651131 - r1651130;
double r1651138 = r1651130 / r1651137;
double r1651139 = r1651136 + r1651138;
return r1651139;
}
double f(double x) {
double r1651140 = 2.0;
double r1651141 = x;
double r1651142 = 1.0;
double r1651143 = r1651142 + r1651141;
double r1651144 = r1651141 * r1651143;
double r1651145 = r1651140 / r1651144;
double r1651146 = r1651141 - r1651142;
double r1651147 = r1651145 / r1651146;
return r1651147;
}




Bits error versus x
Results
| Original | 10.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 10.2
rmApplied frac-sub26.4
Applied frac-add25.8
Taylor expanded around inf 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
rmApplied associate-*r/0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019153 +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))))