\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \leq -1.356774142317772 \cdot 10^{+154} \lor \neg \left(x \leq 1.865958468837717 \cdot 10^{+117}\right):\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{\frac{1}{x - 1}}{x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - 1\right) \cdot \left(x - \left(x + 1\right) \cdot 2\right) + x \cdot \left(x + 1\right)}{{x}^{3} - x}\\
\end{array}(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
:precision binary64
(if (or (<= x -1.356774142317772e+154) (not (<= x 1.865958468837717e+117)))
(/
(-
(* (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)))
(/ (/ 1.0 (- x 1.0)) (- x 1.0)))
(- (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(/
(+ (* (- x 1.0) (- x (* (+ x 1.0) 2.0))) (* x (+ x 1.0)))
(- (pow x 3.0) x))))double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
double code(double x) {
double tmp;
if ((x <= -1.356774142317772e+154) || !(x <= 1.865958468837717e+117)) {
tmp = ((((1.0 / (x + 1.0)) - (2.0 / x)) * ((1.0 / (x + 1.0)) - (2.0 / x))) - ((1.0 / (x - 1.0)) / (x - 1.0))) / (((1.0 / (x + 1.0)) - (2.0 / x)) - (1.0 / (x - 1.0)));
} else {
tmp = (((x - 1.0) * (x - ((x + 1.0) * 2.0))) + (x * (x + 1.0))) / (pow(x, 3.0) - x);
}
return tmp;
}




Bits error versus x
Results
| Original | 9.4 |
|---|---|
| Target | 0.3 |
| Herbie | 9.6 |
if x < -1.35677414231777208e154 or 1.8659584688377169e117 < x Initial program 0.0
rmApplied flip-+_binary640
Simplified1.6
Simplified1.6
if -1.35677414231777208e154 < x < 1.8659584688377169e117Initial program 13.0
rmApplied frac-sub_binary6414.2
Applied frac-add_binary6412.6
Simplified12.6
Simplified12.6
Final simplification9.6
herbie shell --seed 2020288
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))