\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1}\\
\mathbf{if}\;t_0 \leq -1762.7922963857577:\\
\;\;\;\;\left(\frac{-2}{x} - 2 \cdot \left(x + {x}^{3}\right)\right) + -2 \cdot {x}^{5}\\
\mathbf{elif}\;t_0 \leq 2.524354896707238 \cdot 10^{-29}:\\
\;\;\;\;\frac{2}{{x}^{3}} + \frac{2}{{x}^{5}}\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := x \cdot \left(1 + x\right)\\
\frac{\left(x - 1\right) \cdot \left(x - \left(1 + x\right) \cdot 2\right) + t_1}{\left(x - 1\right) \cdot t_1}
\end{array}\\
\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 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (- x 1.0)))))
(if (<= t_0 -1762.7922963857577)
(+ (- (/ -2.0 x) (* 2.0 (+ x (pow x 3.0)))) (* -2.0 (pow x 5.0)))
(if (<= t_0 2.524354896707238e-29)
(+ (/ 2.0 (pow x 3.0)) (/ 2.0 (pow x 5.0)))
(let* ((t_1 (* x (+ 1.0 x))))
(/
(+ (* (- x 1.0) (- x (* (+ 1.0 x) 2.0))) t_1)
(* (- x 1.0) t_1)))))))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 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x - 1.0));
double tmp;
if (t_0 <= -1762.7922963857577) {
tmp = ((-2.0 / x) - (2.0 * (x + pow(x, 3.0)))) + (-2.0 * pow(x, 5.0));
} else if (t_0 <= 2.524354896707238e-29) {
tmp = (2.0 / pow(x, 3.0)) + (2.0 / pow(x, 5.0));
} else {
double t_1 = x * (1.0 + x);
tmp = (((x - 1.0) * (x - ((1.0 + x) * 2.0))) + t_1) / ((x - 1.0) * t_1);
}
return tmp;
}




Bits error versus x
Results
| Original | 10.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -1762.7922963857577Initial program 0.0
rmApplied flip--_binary6432.5
Applied frac-add_binary6432.5
Simplified32.5
Simplified32.5
rmApplied add-cbrt-cube_binary6443.5
Simplified43.5
Taylor expanded around 0 0.0
Simplified0.0
if -1762.7922963857577 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 2.52435e-29Initial program 19.7
Taylor expanded around inf 1.1
Simplified1.1
if 2.52435e-29 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 1.0
rmApplied frac-sub_binary641.0
Applied frac-add_binary640.3
Final simplification0.6
herbie shell --seed 2021198
(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))))