Average Error: 14.5 → 0.1
Time: 15.9s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -247.204822595503:\\ \;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\ \mathbf{elif}\;x \le 243.1515967158251:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right) + \mathsf{fma}\left(\frac{-1}{\mathsf{fma}\left(x, x \cdot x, -1\right)}, \mathsf{fma}\left(x, x, 1\right) + x, \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -247.204822595503:\\
\;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\

\mathbf{elif}\;x \le 243.1515967158251:\\
\;\;\;\;\left(\frac{1}{1 + x} - \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right) + \mathsf{fma}\left(\frac{-1}{\mathsf{fma}\left(x, x \cdot x, -1\right)}, \mathsf{fma}\left(x, x, 1\right) + x, \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\

\end{array}
double f(double x) {
        double r4343762 = 1.0;
        double r4343763 = x;
        double r4343764 = r4343763 + r4343762;
        double r4343765 = r4343762 / r4343764;
        double r4343766 = r4343763 - r4343762;
        double r4343767 = r4343762 / r4343766;
        double r4343768 = r4343765 - r4343767;
        return r4343768;
}

double f(double x) {
        double r4343769 = x;
        double r4343770 = -247.204822595503;
        bool r4343771 = r4343769 <= r4343770;
        double r4343772 = -2.0;
        double r4343773 = r4343769 * r4343769;
        double r4343774 = r4343773 * r4343773;
        double r4343775 = r4343772 / r4343774;
        double r4343776 = 2.0;
        double r4343777 = r4343773 * r4343769;
        double r4343778 = r4343776 / r4343777;
        double r4343779 = r4343778 / r4343777;
        double r4343780 = r4343776 / r4343769;
        double r4343781 = r4343780 / r4343769;
        double r4343782 = r4343779 + r4343781;
        double r4343783 = r4343775 - r4343782;
        double r4343784 = 243.1515967158251;
        bool r4343785 = r4343769 <= r4343784;
        double r4343786 = 1.0;
        double r4343787 = r4343786 + r4343769;
        double r4343788 = r4343786 / r4343787;
        double r4343789 = fma(r4343769, r4343769, r4343786);
        double r4343790 = r4343789 + r4343769;
        double r4343791 = -1.0;
        double r4343792 = fma(r4343769, r4343773, r4343791);
        double r4343793 = r4343790 / r4343792;
        double r4343794 = r4343788 - r4343793;
        double r4343795 = r4343791 / r4343792;
        double r4343796 = fma(r4343795, r4343790, r4343793);
        double r4343797 = r4343794 + r4343796;
        double r4343798 = r4343785 ? r4343797 : r4343783;
        double r4343799 = r4343771 ? r4343783 : r4343798;
        return r4343799;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -247.204822595503 or 243.1515967158251 < x

    1. Initial program 29.8

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

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

      \[\leadsto \color{blue}{\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{2}{x \cdot x} + \frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x}\right)}\]
    4. Using strategy rm
    5. Applied associate-/r*0.1

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

    if -247.204822595503 < x < 243.1515967158251

    1. Initial program 0.0

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip3--0.0

      \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{{x}^{3} - {1}^{3}}{x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)}}}\]
    4. Applied associate-/r/0.0

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \left(x + 1\right)}} - \frac{1}{{x}^{3} - {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\]
    6. Applied add-cube-cbrt0.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{1 \cdot \left(x + 1\right)} - \frac{1}{{x}^{3} - {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\]
    7. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\sqrt[3]{1}}{x + 1}} - \frac{1}{{x}^{3} - {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 + x \cdot 1\right)\right)\]
    8. Applied prod-diff0.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -247.204822595503:\\ \;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\ \mathbf{elif}\;x \le 243.1515967158251:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right) + \mathsf{fma}\left(\frac{-1}{\mathsf{fma}\left(x, x \cdot x, -1\right)}, \mathsf{fma}\left(x, x, 1\right) + x, \frac{\mathsf{fma}\left(x, x, 1\right) + x}{\mathsf{fma}\left(x, x \cdot x, -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{2}{\left(x \cdot x\right) \cdot x}}{\left(x \cdot x\right) \cdot x} + \frac{\frac{2}{x}}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x)
  :name "Asymptote A"
  (- (/ 1 (+ x 1)) (/ 1 (- x 1))))