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



Bits error versus x
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 3.8877992514e-7Initial program 59.2
Taylor expanded in x around inf 0.5
Simplified0.2
Applied pow2_binary640.2
Applied pow-flip_binary640.2
Simplified0.2
if 3.8877992514e-7 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 0.1
Applied flip--_binary640.1
Applied associate-/r/_binary640.2
Applied *-un-lft-identity_binary640.2
Applied add-cube-cbrt_binary640.2
Applied times-frac_binary640.2
Applied prod-diff_binary640.2
Applied add-log-exp_binary640.2
Applied fma-udef_binary640.2
Simplified0.2
Final simplification0.2
herbie shell --seed 2022088
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))