\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \leq -1.7391179435211844 \cdot 10^{+91} \lor \neg \left(x \leq 1.1103717260623167 \cdot 10^{+65}\right):\\
\;\;\;\;\sqrt[3]{{\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{{\left(\sqrt[3]{\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}}}\right)}^{6}}\right)}^{3}}\\
\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.7391179435211844e+91) (not (<= x 1.1103717260623167e+65)))
(cbrt
(pow
(*
(cbrt
(/
(-
(* (- (/ 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)))))
(cbrt
(pow
(cbrt
(/
(-
(* (- (/ 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)))))
6.0)))
3.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.7391179435211844e+91) || !(x <= 1.1103717260623167e+65)) {
tmp = cbrt(pow((cbrt(((((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)))) * cbrt(pow(cbrt(((((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)))), 6.0))), 3.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 | 10.1 |
|---|---|
| Target | 0.2 |
| Herbie | 9.8 |
if x < -1.7391179435211844e91 or 1.1103717260623167e65 < x Initial program 7.0
rmApplied flip-+_binary647.0
Simplified9.9
Simplified9.9
rmApplied add-cbrt-cube_binary647.0
Simplified7.0
rmApplied add-cbrt-cube_binary647.0
Simplified7.0
rmApplied add-cube-cbrt_binary647.0
Simplified7.0
Simplified7.0
if -1.7391179435211844e91 < x < 1.1103717260623167e65Initial program 12.0
rmApplied frac-sub_binary6412.0
Applied frac-add_binary6411.5
Simplified11.5
Simplified11.5
Final simplification9.8
herbie shell --seed 2020285
(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))))