\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}double f(double x) {
double r147860 = 1.0;
double r147861 = x;
double r147862 = r147861 + r147860;
double r147863 = r147860 / r147862;
double r147864 = 2.0;
double r147865 = r147864 / r147861;
double r147866 = r147863 - r147865;
double r147867 = r147861 - r147860;
double r147868 = r147860 / r147867;
double r147869 = r147866 + r147868;
return r147869;
}
double f(double x) {
double r147870 = 2.0;
double r147871 = x;
double r147872 = 1.0;
double r147873 = r147871 + r147872;
double r147874 = r147873 * r147871;
double r147875 = r147870 / r147874;
double r147876 = r147871 - r147872;
double r147877 = r147875 / r147876;
return r147877;
}




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