\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \le -108.93030297428587:\\
\;\;\;\;\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 109.900664385492959:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{x \cdot x - 1 \cdot 1}, x - 1, -\frac{2}{x}\right) + \frac{1}{x - 1}\\
\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 ((double) (((double) (((double) (1.0 / ((double) (x + 1.0)))) - ((double) (2.0 / x)))) + ((double) (1.0 / ((double) (x - 1.0))))));
}
double code(double x) {
double VAR;
if ((x <= -108.93030297428587)) {
VAR = ((double) fma(2.0, ((double) (1.0 / ((double) pow(x, 7.0)))), ((double) fma(2.0, ((double) (1.0 / ((double) pow(x, 5.0)))), ((double) (((double) (2.0 / x)) / ((double) (x * x))))))));
} else {
double VAR_1;
if ((x <= 109.90066438549296)) {
VAR_1 = ((double) (((double) fma(((double) (1.0 / ((double) (((double) (x * x)) - ((double) (1.0 * 1.0)))))), ((double) (x - 1.0)), ((double) -(((double) (2.0 / x)))))) + ((double) (1.0 / ((double) (x - 1.0))))));
} else {
VAR_1 = ((double) fma(2.0, ((double) (1.0 / ((double) pow(x, 7.0)))), ((double) fma(2.0, ((double) (1.0 / ((double) pow(x, 5.0)))), ((double) (2.0 / ((double) 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 < -108.93030297428587Initial program 20.7
Taylor expanded around inf 0.5
Simplified0.5
rmApplied cube-mult0.5
Applied associate-/r*0.1
if -108.93030297428587 < x < 109.90066438549296Initial program 0.0
rmApplied flip-+0.0
Applied associate-/r/0.0
Applied fma-neg0.0
if 109.90066438549296 < x Initial program 19.3
Taylor expanded around inf 0.5
Simplified0.5
Final simplification0.2
herbie shell --seed 2020121 +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))))