Average Error: 14.4 → 0.0
Time: 3.6s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4067.847585363629605126334354281425476074 \lor \neg \left(x \le 6197.824943452278603217564523220062255859\right):\\ \;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + \left(x + 1\right)\right)\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -4067.847585363629605126334354281425476074 \lor \neg \left(x \le 6197.824943452278603217564523220062255859\right):\\
\;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\

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

\end{array}
double f(double x) {
        double r121412 = 1.0;
        double r121413 = x;
        double r121414 = r121413 + r121412;
        double r121415 = r121412 / r121414;
        double r121416 = r121413 - r121412;
        double r121417 = r121412 / r121416;
        double r121418 = r121415 - r121417;
        return r121418;
}

double f(double x) {
        double r121419 = x;
        double r121420 = -4067.8475853636296;
        bool r121421 = r121419 <= r121420;
        double r121422 = 6197.824943452279;
        bool r121423 = r121419 <= r121422;
        double r121424 = !r121423;
        bool r121425 = r121421 || r121424;
        double r121426 = 2.0;
        double r121427 = -r121426;
        double r121428 = 6.0;
        double r121429 = pow(r121419, r121428);
        double r121430 = r121427 / r121429;
        double r121431 = 2.0;
        double r121432 = -r121431;
        double r121433 = pow(r121419, r121432);
        double r121434 = 1.0;
        double r121435 = 4.0;
        double r121436 = pow(r121419, r121435);
        double r121437 = r121434 / r121436;
        double r121438 = r121426 * r121437;
        double r121439 = fma(r121426, r121433, r121438);
        double r121440 = r121430 - r121439;
        double r121441 = 1.0;
        double r121442 = r121419 * r121419;
        double r121443 = r121441 * r121441;
        double r121444 = r121442 - r121443;
        double r121445 = r121441 / r121444;
        double r121446 = r121419 + r121441;
        double r121447 = r121441 + r121446;
        double r121448 = r121419 - r121447;
        double r121449 = r121445 * r121448;
        double r121450 = r121425 ? r121440 : r121449;
        return r121450;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -4067.8475853636296 or 6197.824943452279 < x

    1. Initial program 29.0

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

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

      \[\leadsto \color{blue}{\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, \frac{1}{{x}^{2}}, 2 \cdot \frac{1}{{x}^{4}}\right)}\]
    4. Using strategy rm
    5. Applied pow-flip0.0

      \[\leadsto \frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, \color{blue}{{x}^{\left(-2\right)}}, 2 \cdot \frac{1}{{x}^{4}}\right)\]

    if -4067.8475853636296 < x < 6197.824943452279

    1. Initial program 0.0

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

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

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

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

      \[\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)}\]
    8. Using strategy rm
    9. Applied associate--l-0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4067.847585363629605126334354281425476074 \lor \neg \left(x \le 6197.824943452278603217564523220062255859\right):\\ \;\;\;\;\frac{-2}{{x}^{6}} - \mathsf{fma}\left(2, {x}^{\left(-2\right)}, 2 \cdot \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - \left(1 + \left(x + 1\right)\right)\right)\\ \end{array}\]

Reproduce

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