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




Bits error versus x
Results
| Original | 9.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if x < -87.536795478051545Initial program 18.8
Taylor expanded around inf 0.6
Simplified0.6
rmApplied unpow3_binary640.7
Applied associate-/r*_binary640.1
if -87.536795478051545 < x < 94.7577384407540961Initial program 0.0
rmApplied add-cube-cbrt_binary640.1
Applied associate-/r*_binary640.1
if 94.7577384407540961 < x Initial program 19.0
Taylor expanded around inf 0.5
Simplified0.5
Final simplification0.2
herbie shell --seed 2020210
(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))))