\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\mathsf{fma}\left(x, x, x\right)}}{x - 1}double f(double x) {
double r3953391 = 1.0;
double r3953392 = x;
double r3953393 = r3953392 + r3953391;
double r3953394 = r3953391 / r3953393;
double r3953395 = 2.0;
double r3953396 = r3953395 / r3953392;
double r3953397 = r3953394 - r3953396;
double r3953398 = r3953392 - r3953391;
double r3953399 = r3953391 / r3953398;
double r3953400 = r3953397 + r3953399;
return r3953400;
}
double f(double x) {
double r3953401 = 2.0;
double r3953402 = x;
double r3953403 = fma(r3953402, r3953402, r3953402);
double r3953404 = r3953401 / r3953403;
double r3953405 = 1.0;
double r3953406 = r3953402 - r3953405;
double r3953407 = r3953404 / r3953406;
return r3953407;
}




Bits error versus x
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.8
rmApplied *-un-lft-identity9.8
Applied associate-/l*9.8
Simplified9.8
rmApplied frac-sub26.0
Applied frac-add25.4
Taylor expanded around -inf 0.3
rmApplied associate-/r*0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019151 +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))))