Average Error: 14.7 → 0.1
Time: 15.6s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9003244184241789:\\ \;\;\;\;-\left(\left(\frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{2}{x}}{x}\right) + \frac{2}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\right)\\ \mathbf{elif}\;x \le 41603129.67642414569854736328125:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(1 + x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\left(\left(\frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{2}{x}}{x}\right) + \frac{2}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -9003244184241789:\\
\;\;\;\;-\left(\left(\frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{2}{x}}{x}\right) + \frac{2}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\right)\\

\mathbf{elif}\;x \le 41603129.67642414569854736328125:\\
\;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(1 + x\right)\right)\\

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

\end{array}
double f(double x) {
        double r5721920 = 1.0;
        double r5721921 = x;
        double r5721922 = r5721921 + r5721920;
        double r5721923 = r5721920 / r5721922;
        double r5721924 = r5721921 - r5721920;
        double r5721925 = r5721920 / r5721924;
        double r5721926 = r5721923 - r5721925;
        return r5721926;
}

double f(double x) {
        double r5721927 = x;
        double r5721928 = -9003244184241789.0;
        bool r5721929 = r5721927 <= r5721928;
        double r5721930 = 2.0;
        double r5721931 = r5721927 * r5721927;
        double r5721932 = r5721931 * r5721931;
        double r5721933 = r5721930 / r5721932;
        double r5721934 = r5721930 / r5721927;
        double r5721935 = r5721934 / r5721927;
        double r5721936 = r5721933 + r5721935;
        double r5721937 = r5721931 * r5721932;
        double r5721938 = r5721930 / r5721937;
        double r5721939 = r5721936 + r5721938;
        double r5721940 = -r5721939;
        double r5721941 = 41603129.676424146;
        bool r5721942 = r5721927 <= r5721941;
        double r5721943 = 1.0;
        double r5721944 = r5721943 * r5721943;
        double r5721945 = r5721931 - r5721944;
        double r5721946 = r5721943 / r5721945;
        double r5721947 = r5721927 - r5721943;
        double r5721948 = r5721943 + r5721927;
        double r5721949 = r5721947 - r5721948;
        double r5721950 = r5721946 * r5721949;
        double r5721951 = r5721942 ? r5721950 : r5721940;
        double r5721952 = r5721929 ? r5721940 : r5721951;
        return r5721952;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -9003244184241789.0 or 41603129.676424146 < x

    1. Initial program 29.7

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

      \[\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.7

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

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

    if -9003244184241789.0 < x < 41603129.676424146

    1. Initial program 0.8

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

      \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.8

      \[\leadsto \frac{1}{x + 1} - \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)}\]
    5. Applied flip-+0.8

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    6. Applied associate-/r/0.8

      \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    7. Applied distribute-lft-out--0.0

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

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

Reproduce

herbie shell --seed 2019179 
(FPCore (x)
  :name "Asymptote A"
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 (- x 1.0))))