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

\mathbf{elif}\;x \leq 2044.9951033093892:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{x + 1}{x + -1}\\
t_2 := \sqrt[3]{t_1}\\
t_3 := t_2 \cdot t_2\\
\sqrt[3]{{\left(\frac{x}{x + 1} - t_1\right)}^{3}} + \mathsf{fma}\left(-t_2, t_3, t_2 \cdot t_3\right)
\end{array}\\

\mathbf{else}:\\
\;\;\;\;t_0 - {x}^{-4}\\


\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)) (/ 3.0 (pow x 3.0))))))
   (if (<= x -13109.304414431299)
     t_0
     (if (<= x 2044.9951033093892)
       (let* ((t_1 (/ (+ x 1.0) (+ x -1.0)))
              (t_2 (cbrt t_1))
              (t_3 (* t_2 t_2)))
         (+
          (cbrt (pow (- (/ x (+ x 1.0)) t_1) 3.0))
          (fma (- t_2) t_3 (* t_2 t_3))))
       (- t_0 (pow x -4.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)) + (3.0 / pow(x, 3.0)));
	double tmp;
	if (x <= -13109.304414431299) {
		tmp = t_0;
	} else if (x <= 2044.9951033093892) {
		double t_1 = (x + 1.0) / (x + -1.0);
		double t_2 = cbrt(t_1);
		double t_3 = t_2 * t_2;
		tmp = cbrt(pow(((x / (x + 1.0)) - t_1), 3.0)) + fma(-t_2, t_3, (t_2 * t_3));
	} else {
		tmp = t_0 - pow(x, -4.0);
	}
	return tmp;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -13109.304414431299

    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(3 \cdot \frac{1}{x} + \left(3 \cdot \frac{1}{{x}^{3}} + \frac{1}{{x}^{2}}\right)\right)} \]
    3. Simplified0.1

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

    if -13109.304414431299 < x < 2044.99510330938915

    1. Initial program 0.1

      \[\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) \]

    if 2044.99510330938915 < x

    1. Initial program 59.1

      \[\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}}} \]
    4. Applied pow-flip_binary640.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -13109.304414431299:\\ \;\;\;\;\frac{-3}{x} - \left(\frac{1}{x \cdot x} + \frac{3}{{x}^{3}}\right)\\ \mathbf{elif}\;x \leq 2044.9951033093892:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-3}{x} - \left(\frac{1}{x \cdot x} + \frac{3}{{x}^{3}}\right)\right) - {x}^{-4}\\ \end{array} \]

Reproduce

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