Average Error: 29.2 → 0.0
Time: 16.1s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7534224028620261 \lor \neg \left(x \le 7051386931030.59765625\right):\\ \;\;\;\;-\left(\left(\frac{1}{x \cdot x} + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)}{\left(x - 1\right) \cdot \left(x + 1\right)} - \frac{1}{x - 1} \cdot 1\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -7534224028620261 \lor \neg \left(x \le 7051386931030.59765625\right):\\
\;\;\;\;-\left(\left(\frac{1}{x \cdot x} + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r91418 = x;
        double r91419 = 1.0;
        double r91420 = r91418 + r91419;
        double r91421 = r91418 / r91420;
        double r91422 = r91418 - r91419;
        double r91423 = r91420 / r91422;
        double r91424 = r91421 - r91423;
        return r91424;
}

double f(double x) {
        double r91425 = x;
        double r91426 = -7534224028620261.0;
        bool r91427 = r91425 <= r91426;
        double r91428 = 7051386931030.598;
        bool r91429 = r91425 <= r91428;
        double r91430 = !r91429;
        bool r91431 = r91427 || r91430;
        double r91432 = 1.0;
        double r91433 = r91425 * r91425;
        double r91434 = r91432 / r91433;
        double r91435 = 3.0;
        double r91436 = r91435 / r91425;
        double r91437 = r91434 + r91436;
        double r91438 = 3.0;
        double r91439 = pow(r91425, r91438);
        double r91440 = r91435 / r91439;
        double r91441 = r91437 + r91440;
        double r91442 = -r91441;
        double r91443 = r91425 - r91432;
        double r91444 = r91425 + r91432;
        double r91445 = r91443 - r91444;
        double r91446 = r91425 * r91445;
        double r91447 = r91443 * r91444;
        double r91448 = r91446 / r91447;
        double r91449 = 1.0;
        double r91450 = r91449 / r91443;
        double r91451 = r91450 * r91432;
        double r91452 = r91448 - r91451;
        double r91453 = r91431 ? r91442 : r91452;
        return r91453;
}

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 < -7534224028620261.0 or 7051386931030.598 < x

    1. Initial program 60.4

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

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

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{1}{x - 1}} \cdot \left(x + 1\right)\]
    6. Using strategy rm
    7. Applied distribute-lft-in60.5

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

      \[\leadsto \color{blue}{\left(\frac{x}{x + 1} - \frac{1}{x - 1} \cdot x\right) - \frac{1}{x - 1} \cdot 1}\]
    9. Simplified52.6

      \[\leadsto \color{blue}{\left(\frac{x}{x + 1} - \frac{x}{x - 1}\right)} - \frac{1}{x - 1} \cdot 1\]
    10. Taylor expanded around inf 0.3

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

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

    if -7534224028620261.0 < x < 7051386931030.598

    1. Initial program 1.0

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

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

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{1}{x - 1}} \cdot \left(x + 1\right)\]
    6. Using strategy rm
    7. Applied distribute-lft-in1.0

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

      \[\leadsto \color{blue}{\left(\frac{x}{x + 1} - \frac{1}{x - 1} \cdot x\right) - \frac{1}{x - 1} \cdot 1}\]
    9. Simplified1.0

      \[\leadsto \color{blue}{\left(\frac{x}{x + 1} - \frac{x}{x - 1}\right)} - \frac{1}{x - 1} \cdot 1\]
    10. Using strategy rm
    11. Applied frac-sub1.0

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot x}{\left(x + 1\right) \cdot \left(x - 1\right)}} - \frac{1}{x - 1} \cdot 1\]
    12. Simplified0.0

      \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)} - \frac{1}{x - 1} \cdot 1\]
    13. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7534224028620261 \lor \neg \left(x \le 7051386931030.59765625\right):\\ \;\;\;\;-\left(\left(\frac{1}{x \cdot x} + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)}{\left(x - 1\right) \cdot \left(x + 1\right)} - \frac{1}{x - 1} \cdot 1\\ \end{array}\]

Reproduce

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