\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{1}{\mathsf{fma}\left(x, x, x\right)} \cdot \frac{2}{x - 1}double f(double x) {
double r6684486 = 1.0;
double r6684487 = x;
double r6684488 = r6684487 + r6684486;
double r6684489 = r6684486 / r6684488;
double r6684490 = 2.0;
double r6684491 = r6684490 / r6684487;
double r6684492 = r6684489 - r6684491;
double r6684493 = r6684487 - r6684486;
double r6684494 = r6684486 / r6684493;
double r6684495 = r6684492 + r6684494;
return r6684495;
}
double f(double x) {
double r6684496 = 1.0;
double r6684497 = x;
double r6684498 = fma(r6684497, r6684497, r6684497);
double r6684499 = r6684496 / r6684498;
double r6684500 = 2.0;
double r6684501 = r6684497 - r6684496;
double r6684502 = r6684500 / r6684501;
double r6684503 = r6684499 * r6684502;
return r6684503;
}




Bits error versus x
| Original | 9.4 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.4
rmApplied frac-sub26.0
Applied frac-add25.3
Simplified25.7
Taylor expanded around 0 0.3
rmApplied *-un-lft-identity0.3
Applied times-frac0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2019146 +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))))