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




Bits error versus x
Results
| Original | 9.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if x < -105902111.7533293 or 1149.52584514347814 < x Initial program 19.2
Taylor expanded around inf 0.5
Simplified0.5
if -105902111.7533293 < x < 1149.52584514347814Initial program 0.3
rmApplied frac-sub_binary640.3
Applied frac-add_binary640.0
Simplified0.0
Simplified0.0
Final simplification0.3
herbie shell --seed 2020220
(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))))