\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\begin{array}{l}
\mathbf{if}\;x \leq -218778.51422173358:\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) \cdot \frac{\frac{\frac{2}{x \cdot x}}{x - 1}}{\frac{1}{x + 1} - \frac{2}{x}}\\
\mathbf{elif}\;x \leq 299129.8760379891:\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{x + 1} + \frac{2}{x}\right) \cdot \frac{\frac{2}{x}}{x}}{\left(x - 1\right) \cdot \left(\frac{1}{x + 1} + \frac{2}{x}\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 -218778.51422173358)
(*
(- (/ 1.0 (+ x 1.0)) (/ 2.0 x))
(/ (/ (/ 2.0 (* x x)) (- x 1.0)) (- (/ 1.0 (+ x 1.0)) (/ 2.0 x))))
(if (<= x 299129.8760379891)
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0)))
(/
(* (+ (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ (/ 2.0 x) x))
(* (- x 1.0) (+ (/ 1.0 (+ x 1.0)) (/ 2.0 x)))))))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 <= -218778.51422173358)) {
tmp = ((double) (((double) ((1.0 / ((double) (x + 1.0))) - (2.0 / x))) * (((2.0 / ((double) (x * x))) / ((double) (x - 1.0))) / ((double) ((1.0 / ((double) (x + 1.0))) - (2.0 / x))))));
} else {
double tmp_1;
if ((x <= 299129.8760379891)) {
tmp_1 = ((double) (((double) ((1.0 / ((double) (x + 1.0))) - (2.0 / x))) + (1.0 / ((double) (x - 1.0)))));
} else {
tmp_1 = (((double) (((double) ((1.0 / ((double) (x + 1.0))) + (2.0 / x))) * ((2.0 / x) / x))) / ((double) (((double) (x - 1.0)) * ((double) ((1.0 / ((double) (x + 1.0))) + (2.0 / x))))));
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x
Results
| Original | 9.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.5 |
if x < -218778.514221733582Initial program 19.8
rmApplied flip--_binary6453.7
Applied frac-add_binary6454.5
Simplified25.4
Simplified25.4
Taylor expanded around -inf 0.7
Simplified0.7
rmApplied flip-+_binary6432.1
Applied associate-*r/_binary6432.1
Applied associate-/r/_binary6432.0
Simplified0.7
if -218778.514221733582 < x < 299129.876037989103Initial program 0.3
if 299129.876037989103 < x Initial program 19.4
rmApplied flip--_binary6454.2
Applied frac-add_binary6454.9
Simplified24.9
Simplified24.9
Taylor expanded around -inf 0.8
Simplified0.8
rmApplied associate-/r*_binary640.8
Final simplification0.5
herbie shell --seed 2020204
(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))))