\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 r123942 = 1.0;
double r123943 = x;
double r123944 = r123943 + r123942;
double r123945 = r123942 / r123944;
double r123946 = 2.0;
double r123947 = r123946 / r123943;
double r123948 = r123945 - r123947;
double r123949 = r123943 - r123942;
double r123950 = r123942 / r123949;
double r123951 = r123948 + r123950;
return r123951;
}
double f(double x) {
double r123952 = 2.0;
double r123953 = x;
double r123954 = 1.0;
double r123955 = r123953 + r123954;
double r123956 = r123955 * r123953;
double r123957 = r123952 / r123956;
double r123958 = r123953 - r123954;
double r123959 = r123957 / r123958;
return r123959;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 9.9
rmApplied frac-sub26.3
Applied frac-add25.8
Simplified26.1
Taylor expanded around 0 0.3
rmApplied associate-/r*0.1
Final simplification0.1
herbie shell --seed 2020060 +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))))