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




Bits error versus x
Results
| Original | 9.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
if x < -133969169.14947066Initial program 18.1
Taylor expanded around inf 0.4
Simplified0.4
rmApplied unpow3_binary640.5
Applied associate-/r*_binary640.1
if -133969169.14947066 < x < 724.96718784468544Initial program 0.3
rmApplied frac-sub_binary640.3
Applied frac-add_binary640.0
Simplified0.0
Simplified0.0
if 724.96718784468544 < x Initial program 20.4
Taylor expanded around inf 0.4
Simplified0.4
rmApplied cube-mult_binary640.5
Applied associate-/r*_binary640.1
Final simplification0.1
herbie shell --seed 2020219
(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))))