Average Error: 29.4 → 0.1
Time: 4.2s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12879.754469549705 \lor \neg \left(x \le 12731.4055384574767\right):\\ \;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(x \cdot \left(x \cdot x - 1 \cdot 1\right)\right) \cdot \left(\left(x - 1\right) \cdot \left(x - 1\right)\right) - \left(x + 1\right) \cdot \left(\left(x \cdot x - 1 \cdot 1\right) \cdot \left(x \cdot x - 1 \cdot 1\right)\right)}{\left(x + 1\right) \cdot \left(\left(x - 1\right) \cdot \left(x - 1\right)\right)}}{x \cdot x - 1 \cdot 1}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -12879.754469549705 \lor \neg \left(x \le 12731.4055384574767\right):\\
\;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\

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

\end{array}
double f(double x) {
        double r86560 = x;
        double r86561 = 1.0;
        double r86562 = r86560 + r86561;
        double r86563 = r86560 / r86562;
        double r86564 = r86560 - r86561;
        double r86565 = r86562 / r86564;
        double r86566 = r86563 - r86565;
        return r86566;
}

double f(double x) {
        double r86567 = x;
        double r86568 = -12879.754469549705;
        bool r86569 = r86567 <= r86568;
        double r86570 = 12731.405538457477;
        bool r86571 = r86567 <= r86570;
        double r86572 = !r86571;
        bool r86573 = r86569 || r86572;
        double r86574 = 1.0;
        double r86575 = -r86574;
        double r86576 = 2.0;
        double r86577 = pow(r86567, r86576);
        double r86578 = r86575 / r86577;
        double r86579 = 3.0;
        double r86580 = r86579 / r86567;
        double r86581 = r86578 - r86580;
        double r86582 = 3.0;
        double r86583 = pow(r86567, r86582);
        double r86584 = r86579 / r86583;
        double r86585 = r86581 - r86584;
        double r86586 = r86567 * r86567;
        double r86587 = r86574 * r86574;
        double r86588 = r86586 - r86587;
        double r86589 = r86567 * r86588;
        double r86590 = r86567 - r86574;
        double r86591 = r86590 * r86590;
        double r86592 = r86589 * r86591;
        double r86593 = r86567 + r86574;
        double r86594 = r86588 * r86588;
        double r86595 = r86593 * r86594;
        double r86596 = r86592 - r86595;
        double r86597 = r86593 * r86591;
        double r86598 = r86596 / r86597;
        double r86599 = r86598 / r86588;
        double r86600 = r86573 ? r86585 : r86599;
        return r86600;
}

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 < -12879.754469549705 or 12731.405538457477 < x

    1. Initial program 59.2

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. 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)}\]
    3. Simplified0.0

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

    if -12879.754469549705 < x < 12731.405538457477

    1. Initial program 0.1

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

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

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}} - \frac{\left(x \cdot x - 1 \cdot 1\right) \cdot \left(x \cdot x - 1 \cdot 1\right)}{\left(x - 1\right) \cdot \left(x - 1\right)}}{x \cdot x - 1 \cdot 1}\]
    10. Applied associate-*r/0.1

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

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

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

Reproduce

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