\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1} \leq -5.287715659210365 \cdot 10^{-13} \lor \neg \left(\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1} \leq 0\right):\\
\;\;\;\;\frac{\left(x - 1\right) \cdot \left(x - \left(1 + x\right) \cdot 2\right) + x \cdot \left(1 + x\right)}{\left(x - 1\right) \cdot \left(x \cdot \left(1 + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\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 (<=
(+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (- x 1.0)))
-5.287715659210365e-13)
(not (<= (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (- x 1.0))) 0.0)))
(/
(+ (* (- x 1.0) (- x (* (+ 1.0 x) 2.0))) (* x (+ 1.0 x)))
(* (- x 1.0) (* x (+ 1.0 x))))
(* 2.0 (pow x -3.0))))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 (((((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x - 1.0))) <= -5.287715659210365e-13) || !((((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x - 1.0))) <= 0.0)) {
tmp = (((x - 1.0) * (x - ((1.0 + x) * 2.0))) + (x * (1.0 + x))) / ((x - 1.0) * (x * (1.0 + x)));
} else {
tmp = 2.0 * pow(x, -3.0);
}
return tmp;
}













Bits error versus x
Results
| Original | 9.3 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 8776 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 3976 |
| Alternative 3 | |
|---|---|
| Error | 9.3 |
| Cost | 960 |
| Alternative 4 | |
|---|---|
| Error | 9.7 |
| Cost | 1218 |
| Alternative 5 | |
|---|---|
| Error | 9.8 |
| Cost | 1218 |
| Alternative 6 | |
|---|---|
| Error | 9.9 |
| Cost | 1090 |
| Alternative 7 | |
|---|---|
| Error | 10.1 |
| Cost | 834 |
| Alternative 8 | |
|---|---|
| Error | 41.7 |
| Cost | 64 |
| Alternative 9 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |

if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -5.287715659e-13 or 0.0 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 0.9
rmApplied add-sqr-sqrt_binary64_11230.9
Applied associate-/l*_binary64_10460.9
Simplified0.9
rmApplied inv-pow_binary64_11860.9
rmApplied unpow-1_binary64_11580.9
Applied frac-sub_binary64_11100.9
Applied frac-add_binary64_11090.5
Simplified0.5
Simplified0.5
Simplified0.5
if -5.287715659e-13 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 0.0Initial program 18.6
rmApplied add-exp-log_binary64_113918.8
Simplified18.8
Taylor expanded around -inf 64.0
Simplified0.1
Simplified0.1
Final simplification0.3
herbie shell --seed 2021014
(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))))