\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
t_0 := \frac{2}{{x}^{7}}\\
t_1 := \frac{2}{{x}^{5}}\\
\mathbf{if}\;x \leq -1.0063945433797883:\\
\;\;\;\;t_1 + \left({\left(\frac{{2}^{0.3333333333333333}}{x}\right)}^{3} + t_0\right)\\
\mathbf{elif}\;x \leq 0.9945083062221113:\\
\;\;\;\;-\mathsf{fma}\left(2, x + {x}^{3}, \frac{2}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(\frac{2}{{x}^{3}} + t_0\right)\\
\end{array}
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 2.0 (pow x 7.0))) (t_1 (/ 2.0 (pow x 5.0))))
(if (<= x -1.0063945433797883)
(+ t_1 (+ (pow (/ (pow 2.0 0.3333333333333333) x) 3.0) t_0))
(if (<= x 0.9945083062221113)
(- (fma 2.0 (+ x (pow x 3.0)) (/ 2.0 x)))
(+ t_1 (+ (/ 2.0 (pow x 3.0)) t_0))))))double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
double code(double x) {
double t_0 = 2.0 / pow(x, 7.0);
double t_1 = 2.0 / pow(x, 5.0);
double tmp;
if (x <= -1.0063945433797883) {
tmp = t_1 + (pow((pow(2.0, 0.3333333333333333) / x), 3.0) + t_0);
} else if (x <= 0.9945083062221113) {
tmp = -fma(2.0, (x + pow(x, 3.0)), (2.0 / x));
} else {
tmp = t_1 + ((2.0 / pow(x, 3.0)) + t_0);
}
return tmp;
}




Bits error versus x
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
if x < -1.00639454337978829Initial program 19.4
Taylor expanded in x around inf 0.8
Simplified0.8
Applied egg-rr0.9
Applied egg-rr0.5
if -1.00639454337978829 < x < 0.994508306222111282Initial program 0.0
Taylor expanded in x around 0 0.3
Simplified0.3
if 0.994508306222111282 < x Initial program 19.6
Taylor expanded in x around inf 0.7
Simplified0.7
Final simplification0.4
herbie shell --seed 2022127
(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))))