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):\\ \;\;\;\;\frac{-1}{x \cdot x} - \left(\frac{3}{{x}^{3}} + \frac{3}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(x + 1\right)\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):\\
\;\;\;\;\frac{-1}{x \cdot x} - \left(\frac{3}{{x}^{3}} + \frac{3}{x}\right)\\

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

\end{array}
double f(double x) {
        double r74691 = x;
        double r74692 = 1.0;
        double r74693 = r74691 + r74692;
        double r74694 = r74691 / r74693;
        double r74695 = r74691 - r74692;
        double r74696 = r74693 / r74695;
        double r74697 = r74694 - r74696;
        return r74697;
}

double f(double x) {
        double r74698 = x;
        double r74699 = -7534224028620261.0;
        bool r74700 = r74698 <= r74699;
        double r74701 = 7051386931030.598;
        bool r74702 = r74698 <= r74701;
        double r74703 = !r74702;
        bool r74704 = r74700 || r74703;
        double r74705 = 1.0;
        double r74706 = -r74705;
        double r74707 = r74698 * r74698;
        double r74708 = r74706 / r74707;
        double r74709 = 3.0;
        double r74710 = 3.0;
        double r74711 = pow(r74698, r74710);
        double r74712 = r74709 / r74711;
        double r74713 = r74709 / r74698;
        double r74714 = r74712 + r74713;
        double r74715 = r74708 - r74714;
        double r74716 = r74705 * r74705;
        double r74717 = r74707 - r74716;
        double r74718 = r74698 / r74717;
        double r74719 = r74698 - r74705;
        double r74720 = r74698 + r74705;
        double r74721 = r74719 - r74720;
        double r74722 = r74718 * r74721;
        double r74723 = 1.0;
        double r74724 = r74723 / r74719;
        double r74725 = r74724 * r74705;
        double r74726 = r74722 - r74725;
        double r74727 = r74704 ? r74715 : r74726;
        return r74727;
}

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. 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)}\]
    7. Simplified0.0

      \[\leadsto \color{blue}{\frac{-1}{x \cdot x} - \left(\frac{3}{{x}^{3}} + \frac{3}{x}\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 flip--1.0

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

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

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

      \[\leadsto \left(\color{blue}{\frac{x}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{x}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\right) - \frac{1}{x - 1} \cdot 1\]
    15. Applied distribute-lft-out--0.0

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