\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \le -5.4337115324627003 \lor \neg \left(\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \le 0.0\right):\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} + \frac{2}{x}\right) \cdot \left(2 \cdot \left(\left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)\right)}{\left(\frac{1}{x + 1} + \frac{2}{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 VAR;
if ((((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))) <= -5.4337115324627) || !((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))) <= 0.0))) {
VAR = (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)));
} else {
VAR = ((((1.0 / (x + 1.0)) + (2.0 / x)) * (2.0 * ((pow(x, -2.0) + (1.0 / pow(x, 4.0))) - (1.0 / pow(x, 3.0))))) / (((1.0 / (x + 1.0)) + (2.0 / x)) * (x - 1.0)));
}
return VAR;
}




Bits error versus x
Results
| Original | 9.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))) < -5.4337115324627 or 0.0 < (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))) Initial program 0.7
if -5.4337115324627 < (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))) < 0.0Initial program 18.9
rmApplied flip--53.1
Applied frac-add54.0
Simplified25.0
Taylor expanded around inf 0.4
Simplified0.4
rmApplied pow-flip0.4
Final simplification0.6
herbie shell --seed 2020091
(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))))