Average Error: 29.8 → 0.0
Time: 9.4s
Precision: binary64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1951.0124275398869 \lor \neg \left(x \leq 2044.9951033093892\right):\\ \;\;\;\;\left(\frac{-3}{x} - \left(\frac{1}{x \cdot x} + \frac{3}{{x}^{3}}\right)\right) - \frac{1}{{x}^{4}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{x + 1}{x + -1}\\ t_1 := \sqrt[3]{t_0}\\ t_2 := t_1 \cdot t_1\\ \sqrt[3]{{\left(\frac{x}{x + 1} - t_0\right)}^{3}} + \mathsf{fma}\left(-t_1, t_2, t_1 \cdot t_2\right) \end{array}\\ \end{array} \]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \leq -1951.0124275398869 \lor \neg \left(x \leq 2044.9951033093892\right):\\
\;\;\;\;\left(\frac{-3}{x} - \left(\frac{1}{x \cdot x} + \frac{3}{{x}^{3}}\right)\right) - \frac{1}{{x}^{4}}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \sqrt[3]{t_0}\\
t_2 := t_1 \cdot t_1\\
\sqrt[3]{{\left(\frac{x}{x + 1} - t_0\right)}^{3}} + \mathsf{fma}\left(-t_1, t_2, t_1 \cdot 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
 (if (or (<= x -1951.0124275398869) (not (<= x 2044.9951033093892)))
   (-
    (- (/ -3.0 x) (+ (/ 1.0 (* x x)) (/ 3.0 (pow x 3.0))))
    (/ 1.0 (pow x 4.0)))
   (let* ((t_0 (/ (+ x 1.0) (+ x -1.0))) (t_1 (cbrt t_0)) (t_2 (* t_1 t_1)))
     (+
      (cbrt (pow (- (/ x (+ x 1.0)) t_0) 3.0))
      (fma (- t_1) t_2 (* t_1 t_2))))))
double code(double x) {
	return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
double code(double x) {
	double tmp;
	if ((x <= -1951.0124275398869) || !(x <= 2044.9951033093892)) {
		tmp = ((-3.0 / x) - ((1.0 / (x * x)) + (3.0 / pow(x, 3.0)))) - (1.0 / pow(x, 4.0));
	} else {
		double t_0 = (x + 1.0) / (x + -1.0);
		double t_1 = cbrt(t_0);
		double t_2 = t_1 * t_1;
		tmp = cbrt(pow(((x / (x + 1.0)) - t_0), 3.0)) + fma(-t_1, t_2, (t_1 * t_2));
	}
	return tmp;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -1951.01242753988686 or 2044.99510330938915 < x

    1. Initial program 58.8

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

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

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

    if -1951.01242753988686 < x < 2044.99510330938915

    1. Initial program 0.0

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\left(\sqrt[3]{\frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x + 1}{x - 1}}\right) \cdot \sqrt[3]{\frac{x + 1}{x - 1}}} \]
    3. Applied *-un-lft-identity_binary640.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{x}{x + 1}, -\sqrt[3]{\frac{x + 1}{x - 1}} \cdot \left(\sqrt[3]{\frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x + 1}{x - 1}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{x + 1}{x - 1}}, \sqrt[3]{\frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x + 1}{x - 1}}, \sqrt[3]{\frac{x + 1}{x - 1}} \cdot \left(\sqrt[3]{\frac{x + 1}{x - 1}} \cdot \sqrt[3]{\frac{x + 1}{x - 1}}\right)\right)} \]
    5. Applied add-cbrt-cube_binary640.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1951.0124275398869 \lor \neg \left(x \leq 2044.9951033093892\right):\\ \;\;\;\;\left(\frac{-3}{x} - \left(\frac{1}{x \cdot x} + \frac{3}{{x}^{3}}\right)\right) - \frac{1}{{x}^{4}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x}{x + 1} - \frac{x + 1}{x + -1}\right)}^{3}} + \mathsf{fma}\left(-\sqrt[3]{\frac{x + 1}{x + -1}}, \sqrt[3]{\frac{x + 1}{x + -1}} \cdot \sqrt[3]{\frac{x + 1}{x + -1}}, \sqrt[3]{\frac{x + 1}{x + -1}} \cdot \left(\sqrt[3]{\frac{x + 1}{x + -1}} \cdot \sqrt[3]{\frac{x + 1}{x + -1}}\right)\right)\\ \end{array} \]

Reproduce

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