\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -113.48504878618368 \lor \neg \left(x \le 114.931238552677243\right):\\
\;\;\;\;2 \cdot \left(\frac{1}{{x}^{7}} + \left(\frac{1}{{x}^{5}} + {x}^{\left(-3\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x} + \frac{1}{x - 1}\\
\end{array}double code(double x) {
return (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)));
}
double code(double x) {
double VAR;
if (((x <= -113.48504878618368) || !(x <= 114.93123855267724))) {
VAR = (2.0 * ((1.0 / pow(x, 7.0)) + ((1.0 / pow(x, 5.0)) + pow(x, -3.0))));
} else {
VAR = ((((1.0 * x) - ((x + 1.0) * 2.0)) / ((x + 1.0) * x)) + (1.0 / (x - 1.0)));
}
return VAR;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.0 |
if x < -113.48504878618368 or 114.93123855267724 < x Initial program 19.9
Taylor expanded around inf 0.5
Simplified0.5
rmApplied pow-flip0.0
if -113.48504878618368 < x < 114.93123855267724Initial program 0.0
rmApplied frac-sub0.1
Final simplification0.0
herbie shell --seed 2020079
(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))))