\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 -7.643396633563098:\\
\;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{-1}{1 - x}\\
\mathbf{elif}\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1} \leq 4.5263323118901674 \cdot 10^{-21}:\\
\;\;\;\;\left(\left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{5}}\right) + \frac{2}{{x}^{7}}\right) + \frac{2}{{x}^{9}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 + \left(\frac{1}{x} \cdot -2 + {x}^{3} \cdot -2\right)\\
\end{array}(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
:precision binary64
(if (<=
(+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (- x 1.0)))
-7.643396633563098)
(+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ -1.0 (- 1.0 x)))
(if (<=
(+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (- x 1.0)))
4.5263323118901674e-21)
(+
(+ (+ (/ (/ 2.0 x) (* x x)) (/ 2.0 (pow x 5.0))) (/ 2.0 (pow x 7.0)))
(/ 2.0 (pow x 9.0)))
(+ (* x -2.0) (+ (* (/ 1.0 x) -2.0) (* (pow x 3.0) -2.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))) <= -7.643396633563098) {
tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (-1.0 / (1.0 - x));
} else if ((((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x - 1.0))) <= 4.5263323118901674e-21) {
tmp = ((((2.0 / x) / (x * x)) + (2.0 / pow(x, 5.0))) + (2.0 / pow(x, 7.0))) + (2.0 / pow(x, 9.0));
} else {
tmp = (x * -2.0) + (((1.0 / x) * -2.0) + (pow(x, 3.0) * -2.0));
}
return tmp;
}




Bits error versus x
Results
| Original | 10.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.5 |
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -7.6433966335630981Initial program 0.0
rmApplied frac-2neg_binary64_11120.0
Simplified0.0
Simplified0.0
if -7.6433966335630981 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 4.52633e-21Initial program 19.9
Taylor expanded around inf 0.6
Simplified0.6
rmApplied cube-mult_binary64_11310.6
Applied associate-/r*_binary64_10450.2
if 4.52633e-21 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 0.5
Taylor expanded around 0 1.5
Final simplification0.5
herbie shell --seed 2021075
(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))))