Average Error: 14.4 → 0.1
Time: 16.5s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -210.3545552121263142453244654461741447449:\\ \;\;\;\;-\left(\frac{\frac{2}{x}}{x} + \left(\frac{2}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)} + \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}\right)\right)\\ \mathbf{elif}\;x \le 285.1259381968661728024017065763473510742:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(1, 1 - x, x \cdot x\right), \frac{1}{\mathsf{fma}\left(x, x \cdot x, 1 \cdot \left(1 \cdot 1\right)\right)}, \left(1 + x\right) \cdot \frac{-1}{x \cdot x - 1 \cdot 1}\right) + \mathsf{fma}\left(-\left(1 + x\right), \frac{1}{x \cdot x - 1 \cdot 1}, \left(1 + x\right) \cdot \frac{1}{x \cdot x - 1 \cdot 1}\right)\\ \mathbf{else}:\\ \;\;\;\;-\left(\frac{\frac{2}{x}}{x} + \left(\frac{2}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)} + \frac{2}{\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 -210.3545552121263142453244654461741447449:\\
\;\;\;\;-\left(\frac{\frac{2}{x}}{x} + \left(\frac{2}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)} + \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}\right)\right)\\

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

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

\end{array}
double f(double x) {
        double r5502228 = 1.0;
        double r5502229 = x;
        double r5502230 = r5502229 + r5502228;
        double r5502231 = r5502228 / r5502230;
        double r5502232 = r5502229 - r5502228;
        double r5502233 = r5502228 / r5502232;
        double r5502234 = r5502231 - r5502233;
        return r5502234;
}

double f(double x) {
        double r5502235 = x;
        double r5502236 = -210.35455521212631;
        bool r5502237 = r5502235 <= r5502236;
        double r5502238 = 2.0;
        double r5502239 = r5502238 / r5502235;
        double r5502240 = r5502239 / r5502235;
        double r5502241 = r5502235 * r5502235;
        double r5502242 = r5502241 * r5502241;
        double r5502243 = r5502242 * r5502241;
        double r5502244 = r5502238 / r5502243;
        double r5502245 = r5502238 / r5502242;
        double r5502246 = r5502244 + r5502245;
        double r5502247 = r5502240 + r5502246;
        double r5502248 = -r5502247;
        double r5502249 = 285.1259381968662;
        bool r5502250 = r5502235 <= r5502249;
        double r5502251 = 1.0;
        double r5502252 = r5502251 - r5502235;
        double r5502253 = fma(r5502251, r5502252, r5502241);
        double r5502254 = r5502251 * r5502251;
        double r5502255 = r5502251 * r5502254;
        double r5502256 = fma(r5502235, r5502241, r5502255);
        double r5502257 = r5502251 / r5502256;
        double r5502258 = r5502251 + r5502235;
        double r5502259 = -r5502251;
        double r5502260 = r5502241 - r5502254;
        double r5502261 = r5502259 / r5502260;
        double r5502262 = r5502258 * r5502261;
        double r5502263 = fma(r5502253, r5502257, r5502262);
        double r5502264 = -r5502258;
        double r5502265 = r5502251 / r5502260;
        double r5502266 = r5502258 * r5502265;
        double r5502267 = fma(r5502264, r5502265, r5502266);
        double r5502268 = r5502263 + r5502267;
        double r5502269 = r5502250 ? r5502268 : r5502248;
        double r5502270 = r5502237 ? r5502248 : r5502269;
        return r5502270;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -210.35455521212631 or 285.1259381968662 < x

    1. Initial program 28.9

      \[\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(\frac{2}{x \cdot x} + \left(\frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{2}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\right)\right)}\]
    4. Using strategy rm
    5. Applied associate-/r*0.1

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

    if -210.35455521212631 < x < 285.1259381968662

    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 flip3-+0.0

      \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}} - \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}^{3} + {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    7. Applied prod-diff0.0

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

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

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

Reproduce

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