\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \leq -35323144.403240085 \lor \neg \left(x \leq 7216120.091792685\right):\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} + \frac{2}{x}\right) \cdot \left(\left(\frac{2}{x \cdot x} + \frac{2}{{x}^{4}}\right) - \frac{2}{{x}^{3}}\right)}{\left(\frac{1}{x + 1} + \frac{2}{x}\right) \cdot \left(x - 1\right)}\\
\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 -35323144.403240085) (not (<= x 7216120.091792685)))
(/
(*
(+ (/ 1.0 (+ x 1.0)) (/ 2.0 x))
(- (+ (/ 2.0 (* x x)) (/ 2.0 (pow x 4.0))) (/ 2.0 (pow x 3.0))))
(* (+ (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (- 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 <= -35323144.403240085) || !(x <= 7216120.091792685)) {
tmp = (((1.0 / (x + 1.0)) + (2.0 / x)) * (((2.0 / (x * x)) + (2.0 / pow(x, 4.0))) - (2.0 / pow(x, 3.0)))) / (((1.0 / (x + 1.0)) + (2.0 / x)) * (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.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
if x < -35323144.403240085 or 7216120.09179268498 < x Initial program 19.1
rmApplied flip--_binary6453.3
Applied frac-add_binary6454.4
Simplified25.2
Simplified25.2
Taylor expanded around inf 0.2
Simplified0.2
if -35323144.403240085 < x < 7216120.09179268498Initial program 0.5
rmApplied frac-sub_binary640.5
Applied frac-add_binary640.0
Simplified0.0
Simplified0.0
Final simplification0.1
herbie shell --seed 2020275
(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))))