\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \leq -1.3270199621315663 \cdot 10^{+154} \lor \neg \left(x \leq 1.3274650429408704 \cdot 10^{+154}\right):\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right) - \left(x + 1\right) \cdot \frac{\frac{1}{x - 1}}{x \cdot x - 1}}{\left(\frac{1}{x + 1} - \frac{2}{x}\right) - \frac{1}{x - 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\left(x - 1\right) \cdot \left(x - \left(x + 1\right) \cdot 2\right) + x \cdot \left(x + 1\right)}{x \cdot x - 1}\\
\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.3270199621315663e+154) (not (<= x 1.3274650429408704e+154)))
(/
(-
(* (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)))
(* (+ x 1.0) (/ (/ 1.0 (- x 1.0)) (- (* x x) 1.0))))
(- (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(*
(/ 1.0 x)
(/
(+ (* (- x 1.0) (- x (* (+ x 1.0) 2.0))) (* x (+ x 1.0)))
(- (* x x) 1.0)))))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.3270199621315663e+154) || !(x <= 1.3274650429408704e+154)) {
tmp = ((((1.0 / (x + 1.0)) - (2.0 / x)) * ((1.0 / (x + 1.0)) - (2.0 / x))) - ((x + 1.0) * ((1.0 / (x - 1.0)) / ((x * x) - 1.0)))) / (((1.0 / (x + 1.0)) - (2.0 / x)) - (1.0 / (x - 1.0)));
} else {
tmp = (1.0 / x) * ((((x - 1.0) * (x - ((x + 1.0) * 2.0))) + (x * (x + 1.0))) / ((x * x) - 1.0));
}
return tmp;
}




Bits error versus x
Results
| Original | 9.5 |
|---|---|
| Target | 0.3 |
| Herbie | 10.0 |
if x < -1.3270199621315663e154 or 1.32746504294087043e154 < x Initial program 0.0
rmApplied flip-+_binary640
Simplified0
Simplified0
rmApplied flip--_binary642.8
Applied associate-/r/_binary642.8
Simplified2.8
if -1.3270199621315663e154 < x < 1.32746504294087043e154Initial program 12.8
rmApplied frac-sub_binary6414.7
Applied frac-add_binary6412.4
Simplified12.4
Simplified12.4
rmApplied *-un-lft-identity_binary6412.4
Applied distribute-lft-neg-in_binary6412.4
Applied unpow3_binary6412.4
Applied distribute-rgt-out_binary6412.4
Applied *-un-lft-identity_binary6412.4
Applied times-frac_binary6412.4
Simplified12.4
Final simplification10.0
herbie shell --seed 2020277
(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))))