\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -133358930.129605 \lor \neg \left(x \le 449.06402820041797\right):\\
\;\;\;\;2 \cdot \left(\frac{1}{{x}^{7}} + \left(\frac{1}{{x}^{5}} + \frac{1}{{x}^{3}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \cdot x - \left(x + 1\right) \cdot 2\right) \cdot \left(x - 1\right) + \left(\left(x + 1\right) \cdot x\right) \cdot 1}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\\
\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 temp;
if (((x <= -133358930.129605) || !(x <= 449.06402820041797))) {
temp = (2.0 * ((1.0 / pow(x, 7.0)) + ((1.0 / pow(x, 5.0)) + (1.0 / pow(x, 3.0)))));
} else {
temp = (((((1.0 * x) - ((x + 1.0) * 2.0)) * (x - 1.0)) + (((x + 1.0) * x) * 1.0)) / (((x + 1.0) * x) * (x - 1.0)));
}
return temp;
}




Bits error versus x
Results
| Original | 10.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if x < -133358930.129605 or 449.06402820041797 < x Initial program 20.0
Taylor expanded around inf 0.6
Simplified0.6
if -133358930.129605 < x < 449.06402820041797Initial program 0.5
rmApplied frac-sub0.5
Applied frac-add0.0
Final simplification0.3
herbie shell --seed 2020057
(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))))