\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \frac{-1}{x - 1}\\
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x - 1} \leq 2.860045533736866 \cdot 10^{-10}:\\
\;\;\;\;\frac{-3 + \frac{-1}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{-1 + x \cdot x}, x - 1, \left(x + 1\right) \cdot t_0\right) + \mathsf{fma}\left(t_0, x + 1, \left(x + 1\right) \cdot \frac{1}{x - 1}\right)\\
\end{array}
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (- x 1.0))))
(if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))) 2.860045533736866e-10)
(/ (+ -3.0 (/ -1.0 x)) x)
(+
(fma (/ x (+ -1.0 (* x x))) (- x 1.0) (* (+ x 1.0) t_0))
(fma t_0 (+ x 1.0) (* (+ x 1.0) (/ 1.0 (- x 1.0))))))))double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
double t_0 = -1.0 / (x - 1.0);
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))) <= 2.860045533736866e-10) {
tmp = (-3.0 + (-1.0 / x)) / x;
} else {
tmp = fma((x / (-1.0 + (x * x))), (x - 1.0), ((x + 1.0) * t_0)) + fma(t_0, (x + 1.0), ((x + 1.0) * (1.0 / (x - 1.0))));
}
return tmp;
}



Bits error versus x
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 2.8600455e-10Initial program 59.2
Taylor expanded in x around inf 0.7
Simplified0.4
Taylor expanded in x around 0 0.7
Simplified0.4
if 2.8600455e-10 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 0.2
Applied div-inv_binary640.2
Applied flip-+_binary640.2
Applied associate-/r/_binary640.2
Applied prod-diff_binary640.2
Final simplification0.3
herbie shell --seed 2022160
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))