\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{1}{\left(x + 1\right) \cdot x} \cdot \frac{2}{x - 1}double f(double x) {
double r145213 = 1.0;
double r145214 = x;
double r145215 = r145214 + r145213;
double r145216 = r145213 / r145215;
double r145217 = 2.0;
double r145218 = r145217 / r145214;
double r145219 = r145216 - r145218;
double r145220 = r145214 - r145213;
double r145221 = r145213 / r145220;
double r145222 = r145219 + r145221;
return r145222;
}
double f(double x) {
double r145223 = 1.0;
double r145224 = x;
double r145225 = 1.0;
double r145226 = r145224 + r145225;
double r145227 = r145226 * r145224;
double r145228 = r145223 / r145227;
double r145229 = 2.0;
double r145230 = r145224 - r145225;
double r145231 = r145229 / r145230;
double r145232 = r145228 * r145231;
return r145232;
}




Bits error versus x
Results
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.8
rmApplied *-un-lft-identity9.8
Applied *-un-lft-identity9.8
Applied times-frac9.8
Simplified9.8
rmApplied associate-*r/9.8
Applied frac-sub26.2
Applied frac-add25.7
Taylor expanded around 0 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
Final simplification0.1
herbie shell --seed 2020036
(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))))