Average Error: 29.5 → 0.1
Time: 14.6s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -10736.40438136704869975801557302474975586:\\ \;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\ \mathbf{elif}\;x \le 9434.995202559312019729986786842346191406:\\ \;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(x - 1\right) \cdot \left(x \cdot x + \left(1 - x\right) \cdot 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -10736.40438136704869975801557302474975586:\\
\;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\

\mathbf{elif}\;x \le 9434.995202559312019729986786842346191406:\\
\;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(x - 1\right) \cdot \left(x \cdot x + \left(1 - x\right) \cdot 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\

\end{array}
double f(double x) {
        double r6279490 = x;
        double r6279491 = 1.0;
        double r6279492 = r6279490 + r6279491;
        double r6279493 = r6279490 / r6279492;
        double r6279494 = r6279490 - r6279491;
        double r6279495 = r6279492 / r6279494;
        double r6279496 = r6279493 - r6279495;
        return r6279496;
}

double f(double x) {
        double r6279497 = x;
        double r6279498 = -10736.404381367049;
        bool r6279499 = r6279497 <= r6279498;
        double r6279500 = 3.0;
        double r6279501 = r6279497 * r6279497;
        double r6279502 = r6279501 * r6279497;
        double r6279503 = r6279500 / r6279502;
        double r6279504 = exp(r6279503);
        double r6279505 = log(r6279504);
        double r6279506 = -r6279505;
        double r6279507 = 1.0;
        double r6279508 = r6279507 / r6279501;
        double r6279509 = r6279506 - r6279508;
        double r6279510 = r6279500 / r6279497;
        double r6279511 = r6279509 - r6279510;
        double r6279512 = 9434.995202559312;
        bool r6279513 = r6279497 <= r6279512;
        double r6279514 = r6279497 + r6279507;
        double r6279515 = r6279497 / r6279514;
        double r6279516 = 3.0;
        double r6279517 = pow(r6279497, r6279516);
        double r6279518 = pow(r6279507, r6279516);
        double r6279519 = r6279517 + r6279518;
        double r6279520 = r6279497 - r6279507;
        double r6279521 = r6279507 - r6279497;
        double r6279522 = r6279521 * r6279507;
        double r6279523 = r6279501 + r6279522;
        double r6279524 = r6279520 * r6279523;
        double r6279525 = r6279519 / r6279524;
        double r6279526 = r6279515 - r6279525;
        double r6279527 = r6279513 ? r6279526 : r6279511;
        double r6279528 = r6279499 ? r6279511 : r6279527;
        return r6279528;
}

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 < -10736.404381367049 or 9434.995202559312 < x

    1. Initial program 59.3

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Taylor expanded around inf 0.3

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

      \[\leadsto \color{blue}{\left(\left(-\frac{3}{x \cdot \left(x \cdot x\right)}\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.1

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

    if -10736.404381367049 < x < 9434.995202559312

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \frac{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}}{x - 1}\]
    4. Applied associate-/l/0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -10736.40438136704869975801557302474975586:\\ \;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\ \mathbf{elif}\;x \le 9434.995202559312019729986786842346191406:\\ \;\;\;\;\frac{x}{x + 1} - \frac{{x}^{3} + {1}^{3}}{\left(x - 1\right) \cdot \left(x \cdot x + \left(1 - x\right) \cdot 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\log \left(e^{\frac{3}{\left(x \cdot x\right) \cdot x}}\right)\right) - \frac{1}{x \cdot x}\right) - \frac{3}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))