Average Error: 14.4 → 0.0
Time: 2.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}} - 2 \cdot \left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + \left(\left(-1\right) - \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}} - 2 \cdot \left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right)\\

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

\end{array}
double f(double x) {
        double r126224 = 1.0;
        double r126225 = x;
        double r126226 = r126225 + r126224;
        double r126227 = r126224 / r126226;
        double r126228 = r126225 - r126224;
        double r126229 = r126224 / r126228;
        double r126230 = r126227 - r126229;
        return r126230;
}

double f(double x) {
        double r126231 = x;
        double r126232 = -4067.8475853636296;
        bool r126233 = r126231 <= r126232;
        double r126234 = 6197.824943452279;
        bool r126235 = r126231 <= r126234;
        double r126236 = !r126235;
        bool r126237 = r126233 || r126236;
        double r126238 = 2.0;
        double r126239 = -r126238;
        double r126240 = 6.0;
        double r126241 = pow(r126231, r126240);
        double r126242 = r126239 / r126241;
        double r126243 = 2.0;
        double r126244 = -r126243;
        double r126245 = pow(r126231, r126244);
        double r126246 = 1.0;
        double r126247 = 4.0;
        double r126248 = pow(r126231, r126247);
        double r126249 = r126246 / r126248;
        double r126250 = r126245 + r126249;
        double r126251 = r126238 * r126250;
        double r126252 = r126242 - r126251;
        double r126253 = 1.0;
        double r126254 = r126231 * r126231;
        double r126255 = r126253 * r126253;
        double r126256 = r126254 - r126255;
        double r126257 = r126253 / r126256;
        double r126258 = -r126253;
        double r126259 = r126231 + r126253;
        double r126260 = r126258 - r126259;
        double r126261 = r126231 + r126260;
        double r126262 = r126257 * r126261;
        double r126263 = r126237 ? r126252 : r126262;
        return r126263;
}

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 < -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}} - 2 \cdot \left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right)}\]
    4. Using strategy rm
    5. Applied pow-flip0.0

      \[\leadsto \frac{-2}{{x}^{6}} - 2 \cdot \left(\color{blue}{{x}^{\left(-2\right)}} + \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 sub-neg0.0

      \[\leadsto \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\color{blue}{\left(x + \left(-1\right)\right)} - \left(x + 1\right)\right)\]
    10. Applied associate--l+0.0

      \[\leadsto \frac{1}{x \cdot x - 1 \cdot 1} \cdot \color{blue}{\left(x + \left(\left(-1\right) - \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}} - 2 \cdot \left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + \left(\left(-1\right) - \left(x + 1\right)\right)\right)\\ \end{array}\]

Reproduce

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