\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{\frac{2}{x + 1}}{x}}{x - 1}double f(double x) {
double r172337 = 1.0;
double r172338 = x;
double r172339 = r172338 + r172337;
double r172340 = r172337 / r172339;
double r172341 = 2.0;
double r172342 = r172341 / r172338;
double r172343 = r172340 - r172342;
double r172344 = r172338 - r172337;
double r172345 = r172337 / r172344;
double r172346 = r172343 + r172345;
return r172346;
}
double f(double x) {
double r172347 = 2.0;
double r172348 = x;
double r172349 = 1.0;
double r172350 = r172348 + r172349;
double r172351 = r172347 / r172350;
double r172352 = r172351 / r172348;
double r172353 = r172348 - r172349;
double r172354 = r172352 / r172353;
return r172354;
}




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