Average Error: 14.3 → 0.4
Time: 1.7m
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.023793247757054:\\ \;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \left(\frac{-2}{x \cdot x} + \frac{-2}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)}\right)\\ \mathbf{elif}\;x \le 231.23421380922747:\\ \;\;\;\;\frac{\frac{1}{\sqrt{1 + x}}}{\sqrt{1 + x}} - \frac{1}{x - 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{-2}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)} + \frac{\frac{-2}{x}}{x}\right) + \frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -1.023793247757054:\\
\;\;\;\;\frac{-2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \left(\frac{-2}{x \cdot x} + \frac{-2}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)}\right)\\

\mathbf{elif}\;x \le 231.23421380922747:\\
\;\;\;\;\frac{\frac{1}{\sqrt{1 + x}}}{\sqrt{1 + x}} - \frac{1}{x - 1}\\

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

\end{array}
double f(double x) {
        double r5544300 = 1.0;
        double r5544301 = x;
        double r5544302 = r5544301 + r5544300;
        double r5544303 = r5544300 / r5544302;
        double r5544304 = r5544301 - r5544300;
        double r5544305 = r5544300 / r5544304;
        double r5544306 = r5544303 - r5544305;
        return r5544306;
}

double f(double x) {
        double r5544307 = x;
        double r5544308 = -1.023793247757054;
        bool r5544309 = r5544307 <= r5544308;
        double r5544310 = -2.0;
        double r5544311 = r5544307 * r5544307;
        double r5544312 = r5544311 * r5544311;
        double r5544313 = r5544310 / r5544312;
        double r5544314 = r5544310 / r5544311;
        double r5544315 = r5544311 * r5544307;
        double r5544316 = r5544315 * r5544315;
        double r5544317 = r5544310 / r5544316;
        double r5544318 = r5544314 + r5544317;
        double r5544319 = r5544313 + r5544318;
        double r5544320 = 231.23421380922747;
        bool r5544321 = r5544307 <= r5544320;
        double r5544322 = 1.0;
        double r5544323 = r5544322 + r5544307;
        double r5544324 = sqrt(r5544323);
        double r5544325 = r5544322 / r5544324;
        double r5544326 = r5544325 / r5544324;
        double r5544327 = r5544307 - r5544322;
        double r5544328 = r5544322 / r5544327;
        double r5544329 = r5544326 - r5544328;
        double r5544330 = r5544310 / r5544307;
        double r5544331 = r5544330 / r5544307;
        double r5544332 = r5544317 + r5544331;
        double r5544333 = r5544332 + r5544313;
        double r5544334 = r5544321 ? r5544329 : r5544333;
        double r5544335 = r5544309 ? r5544319 : r5544334;
        return r5544335;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 28.3

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

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

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

    if -1.023793247757054 < x < 231.23421380922747

    1. Initial program 0.0

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x + 1}}}{\sqrt{x + 1}}} - \frac{1}{x - 1}\]

    if 231.23421380922747 < x

    1. Initial program 29.6

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

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

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

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

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

Reproduce

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