Average Error: 29.9 → 0.0
Time: 11.9s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} t_0 := \frac{-3}{x} - \frac{1}{x \cdot x}\\ \mathbf{if}\;x \leq -57091482545.71593:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7377809056377330:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x + \left(-2 - x\right), -1\right) - x}{\left(1 - x \cdot x\right) \cdot \left(-1 + {x}^{3}\right)} \cdot \left(\left(1 - x\right) \cdot \left(x \cdot x + \left(x + 1\right)\right)\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 (- (/ -3.0 x) (/ 1.0 (* x x)))))
   (if (<= x -57091482545.71593)
     t_0
     (if (<= x 7377809056377330.0)
       (*
        (/
         (- (fma x (+ x (- -2.0 x)) -1.0) x)
         (* (- 1.0 (* x x)) (+ -1.0 (pow x 3.0))))
        (* (- 1.0 x) (+ (* x x) (+ 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 = (-3.0 / x) - (1.0 / (x * x));
	double tmp;
	if (x <= -57091482545.71593) {
		tmp = t_0;
	} else if (x <= 7377809056377330.0) {
		tmp = ((fma(x, (x + (-2.0 - x)), -1.0) - x) / ((1.0 - (x * x)) * (-1.0 + pow(x, 3.0)))) * ((1.0 - x) * ((x * x) + (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 = Float64(Float64(-3.0 / x) - Float64(1.0 / Float64(x * x)))
	tmp = 0.0
	if (x <= -57091482545.71593)
		tmp = t_0;
	elseif (x <= 7377809056377330.0)
		tmp = Float64(Float64(Float64(fma(x, Float64(x + Float64(-2.0 - x)), -1.0) - x) / Float64(Float64(1.0 - Float64(x * x)) * Float64(-1.0 + (x ^ 3.0)))) * Float64(Float64(1.0 - x) * Float64(Float64(x * x) + 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[(N[(-3.0 / x), $MachinePrecision] - N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -57091482545.71593], t$95$0, If[LessEqual[x, 7377809056377330.0], N[(N[(N[(N[(x * N[(x + N[(-2.0 - x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] - x), $MachinePrecision] / N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
t_0 := \frac{-3}{x} - \frac{1}{x \cdot x}\\
\mathbf{if}\;x \leq -57091482545.71593:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7377809056377330:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x + \left(-2 - x\right), -1\right) - x}{\left(1 - x \cdot x\right) \cdot \left(-1 + {x}^{3}\right)} \cdot \left(\left(1 - x\right) \cdot \left(x \cdot x + \left(x + 1\right)\right)\right)\\

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


\end{array}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -57091482545.715927 or 7377809056377330 < x

    1. Initial program 60.3

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

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

      \[\leadsto \color{blue}{\frac{-3}{x} - \frac{1}{x \cdot x}} \]

    if -57091482545.715927 < x < 7377809056377330

    1. Initial program 0.9

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
    2. Applied add-cube-cbrt_binary640.9

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right) \cdot \sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}} \]
    3. Applied frac-sub_binary640.9

      \[\leadsto \left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right) \cdot \sqrt[3]{\color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}} \]
    4. Applied cbrt-div_binary640.9

      \[\leadsto \left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right) \cdot \color{blue}{\frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}} \]
    5. Applied frac-sub_binary640.9

      \[\leadsto \left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \sqrt[3]{\color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}}\right) \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    6. Applied cbrt-div_binary640.9

      \[\leadsto \left(\sqrt[3]{\frac{x}{x + 1} - \frac{x + 1}{x - 1}} \cdot \color{blue}{\frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}}\right) \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    7. Applied frac-sub_binary640.9

      \[\leadsto \left(\sqrt[3]{\color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}} \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}\right) \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    8. Applied cbrt-div_binary640.9

      \[\leadsto \left(\color{blue}{\frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}} \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}\right) \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    9. Applied frac-times_binary640.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)} \cdot \sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}}} \cdot \frac{\sqrt[3]{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}}{\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    10. Applied frac-times_binary640.9

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, \left(x + -1\right) + \left(-1 - x\right), -1\right) - x}}{\left(\sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}\right) \cdot \sqrt[3]{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    12. Simplified0.0

      \[\leadsto \frac{\mathsf{fma}\left(x, \left(x + -1\right) + \left(-1 - x\right), -1\right) - x}{\color{blue}{\left(1 + x\right) \cdot \left(x + -1\right)}} \]
    13. Applied flip3-+_binary640.0

      \[\leadsto \frac{\mathsf{fma}\left(x, \left(x + -1\right) + \left(-1 - x\right), -1\right) - x}{\left(1 + x\right) \cdot \color{blue}{\frac{{x}^{3} + {-1}^{3}}{x \cdot x + \left(-1 \cdot -1 - x \cdot -1\right)}}} \]
    14. Applied flip-+_binary640.1

      \[\leadsto \frac{\mathsf{fma}\left(x, \left(x + -1\right) + \left(-1 - x\right), -1\right) - x}{\color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 - x}} \cdot \frac{{x}^{3} + {-1}^{3}}{x \cdot x + \left(-1 \cdot -1 - x \cdot -1\right)}} \]
    15. Applied frac-times_binary640.1

      \[\leadsto \frac{\mathsf{fma}\left(x, \left(x + -1\right) + \left(-1 - x\right), -1\right) - x}{\color{blue}{\frac{\left(1 \cdot 1 - x \cdot x\right) \cdot \left({x}^{3} + {-1}^{3}\right)}{\left(1 - x\right) \cdot \left(x \cdot x + \left(-1 \cdot -1 - x \cdot -1\right)\right)}}} \]
    16. Applied associate-/r/_binary640.1

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

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

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

Reproduce

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