\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -89.3311912530264891:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, \frac{\frac{2}{x}}{x \cdot x}\right)\right)\\
\mathbf{elif}\;x \le 99.322725633338678:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}, \frac{1}{\sqrt[3]{x + 1}}, -\frac{2}{x} \cdot 1\right) + \mathsf{fma}\left(\frac{2}{x}, \left(-1\right) + 1, \frac{1}{x - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{1}{{x}^{7}}, \mathsf{fma}\left(2, \frac{1}{{x}^{5}}, \frac{2}{{x}^{3}}\right)\right)\\
\end{array}double code(double x) {
return (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)));
}
double code(double x) {
double VAR;
if ((x <= -89.33119125302649)) {
VAR = fma(2.0, (1.0 / pow(x, 7.0)), fma(2.0, (1.0 / pow(x, 5.0)), ((2.0 / x) / (x * x))));
} else {
double VAR_1;
if ((x <= 99.32272563333868)) {
VAR_1 = (fma((1.0 / (cbrt((x + 1.0)) * cbrt((x + 1.0)))), (1.0 / cbrt((x + 1.0))), -((2.0 / x) * 1.0)) + fma((2.0 / x), (-1.0 + 1.0), (1.0 / (x - 1.0))));
} else {
VAR_1 = fma(2.0, (1.0 / pow(x, 7.0)), fma(2.0, (1.0 / pow(x, 5.0)), (2.0 / pow(x, 3.0))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x
Results
| Original | 9.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if x < -89.33119125302649Initial program 20.4
Taylor expanded around inf 0.5
Simplified0.5
rmApplied cube-mult0.6
Applied associate-/r*0.1
if -89.33119125302649 < x < 99.32272563333868Initial program 0.0
rmApplied *-un-lft-identity0.0
Applied add-cube-cbrt0.0
Applied *-un-lft-identity0.0
Applied times-frac0.0
Applied prod-diff0.0
Applied associate-+l+0.0
Simplified0.0
if 99.32272563333868 < x Initial program 19.3
Taylor expanded around inf 0.5
Simplified0.5
Final simplification0.2
herbie shell --seed 2020079 +o rules:numerics
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2 (* x (- (* x x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))