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




Bits error versus x
Results
| Original | 9.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if x < -17522.19903136883Initial program 20.3
rmApplied flip--_binary64_175853.6
Applied frac-add_binary64_179154.2
Simplified26.4
Simplified26.4
Taylor expanded around inf 0.3
Simplified0.3
rmApplied frac-add_binary64_17910.3
Applied associate-*l/_binary64_17260.3
Applied associate-/l/_binary64_17300.3
Simplified0.3
Taylor expanded around 0 0.2
Simplified0.3
if -17522.19903136883 < x < 604.363338453084566Initial program 0.1
rmApplied frac-sub_binary64_17920.1
if 604.363338453084566 < x Initial program 20.3
Taylor expanded around inf 0.6
Final simplification0.3
herbie shell --seed 2021027
(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))))