Average Error: 29.5 → 0.1
Time: 3.3s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(-1, {x}^{-2}, \mathsf{fma}\left(-3, {x}^{-3}, \frac{-3}{x}\right)\right)\\ \mathbf{if}\;x \leq -6176794.5564302765:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 209.85361716255164:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1}{x + 1}, \frac{\mathsf{fma}\left(-1, x, -1\right)}{x + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fma -1.0 (pow x -2.0) (fma -3.0 (pow x -3.0) (/ -3.0 x)))))
   (if (<= x -6176794.5564302765)
     t_0
     (if (<= x 209.85361716255164)
       (fma x (/ 1.0 (+ x 1.0)) (/ (fma -1.0 x -1.0) (+ x -1.0)))
       t_0))))
double code(double x) {
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
	double t_0 = fma(-1.0, pow(x, -2.0), fma(-3.0, pow(x, -3.0), (-3.0 / x)));
	double tmp;
	if (x <= -6176794.5564302765) {
		tmp = t_0;
	} else if (x <= 209.85361716255164) {
		tmp = fma(x, (1.0 / (x + 1.0)), (fma(-1.0, x, -1.0) / (x + -1.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x)
	return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0)))
end
function code(x)
	t_0 = fma(-1.0, (x ^ -2.0), fma(-3.0, (x ^ -3.0), Float64(-3.0 / x)))
	tmp = 0.0
	if (x <= -6176794.5564302765)
		tmp = t_0;
	elseif (x <= 209.85361716255164)
		tmp = fma(x, Float64(1.0 / Float64(x + 1.0)), Float64(fma(-1.0, x, -1.0) / Float64(x + -1.0)));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(-1.0 * N[Power[x, -2.0], $MachinePrecision] + N[(-3.0 * N[Power[x, -3.0], $MachinePrecision] + N[(-3.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6176794.5564302765], t$95$0, If[LessEqual[x, 209.85361716255164], N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 * x + -1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, {x}^{-2}, \mathsf{fma}\left(-3, {x}^{-3}, \frac{-3}{x}\right)\right)\\
\mathbf{if}\;x \leq -6176794.5564302765:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 209.85361716255164:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1}{x + 1}, \frac{\mathsf{fma}\left(-1, x, -1\right)}{x + -1}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -6176794.5564302765 or 209.85361716255164 < x

    1. Initial program 59.5

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
    2. Taylor expanded in x around inf 0.4

      \[\leadsto \color{blue}{-\left(3 \cdot \frac{1}{{x}^{3}} + \left(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)} \]
    3. Simplified0.1

      \[\leadsto \color{blue}{\frac{-1}{x \cdot x} + \left(\frac{-3}{x} + \frac{-3}{{x}^{3}}\right)} \]
    4. Applied egg-rr0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {x}^{-2}, \mathsf{fma}\left(-3, {x}^{-3}, \frac{-3}{x}\right)\right)} \]

    if -6176794.5564302765 < x < 209.85361716255164

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
    2. Applied egg-rr0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{1}{x + 1}, \frac{\mathsf{fma}\left(-1, x, -1\right)}{x + -1}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6176794.5564302765:\\ \;\;\;\;\mathsf{fma}\left(-1, {x}^{-2}, \mathsf{fma}\left(-3, {x}^{-3}, \frac{-3}{x}\right)\right)\\ \mathbf{elif}\;x \leq 209.85361716255164:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1}{x + 1}, \frac{\mathsf{fma}\left(-1, x, -1\right)}{x + -1}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, {x}^{-2}, \mathsf{fma}\left(-3, {x}^{-3}, \frac{-3}{x}\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022192 
(FPCore (x)
  :name "Asymptote C"
  :precision binary64
  (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))