Average Error: 29.0 → 0.3
Time: 28.6s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -11471.638860480614:\\ \;\;\;\;\left(\log \left(e^{\frac{-1}{x \cdot x}}\right) - \frac{3}{x}\right) - \frac{\frac{3}{x}}{x \cdot x}\\ \mathbf{elif}\;x \le 10055.66846222333:\\ \;\;\;\;\frac{\left(\left(x - 1\right) \cdot \frac{x}{x \cdot x - 1}\right) \cdot \left(\left(x - 1\right) \cdot \frac{x}{x \cdot x - 1}\right) - \frac{1 + x}{x - 1} \cdot \frac{1 + x}{x - 1}}{\frac{1 + x}{x - 1} + \left(x - 1\right) \cdot \frac{x}{x \cdot x - 1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\log \left(e^{\frac{-1}{x \cdot x}}\right) - \frac{3}{x}\right) - \frac{\frac{3}{x}}{x \cdot x}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -11471.638860480614:\\
\;\;\;\;\left(\log \left(e^{\frac{-1}{x \cdot x}}\right) - \frac{3}{x}\right) - \frac{\frac{3}{x}}{x \cdot x}\\

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

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

\end{array}
double f(double x) {
        double r4882498 = x;
        double r4882499 = 1.0;
        double r4882500 = r4882498 + r4882499;
        double r4882501 = r4882498 / r4882500;
        double r4882502 = r4882498 - r4882499;
        double r4882503 = r4882500 / r4882502;
        double r4882504 = r4882501 - r4882503;
        return r4882504;
}

double f(double x) {
        double r4882505 = x;
        double r4882506 = -11471.638860480614;
        bool r4882507 = r4882505 <= r4882506;
        double r4882508 = -1.0;
        double r4882509 = r4882505 * r4882505;
        double r4882510 = r4882508 / r4882509;
        double r4882511 = exp(r4882510);
        double r4882512 = log(r4882511);
        double r4882513 = 3.0;
        double r4882514 = r4882513 / r4882505;
        double r4882515 = r4882512 - r4882514;
        double r4882516 = r4882514 / r4882509;
        double r4882517 = r4882515 - r4882516;
        double r4882518 = 10055.66846222333;
        bool r4882519 = r4882505 <= r4882518;
        double r4882520 = 1.0;
        double r4882521 = r4882505 - r4882520;
        double r4882522 = r4882509 - r4882520;
        double r4882523 = r4882505 / r4882522;
        double r4882524 = r4882521 * r4882523;
        double r4882525 = r4882524 * r4882524;
        double r4882526 = r4882520 + r4882505;
        double r4882527 = r4882526 / r4882521;
        double r4882528 = r4882527 * r4882527;
        double r4882529 = r4882525 - r4882528;
        double r4882530 = r4882527 + r4882524;
        double r4882531 = r4882529 / r4882530;
        double r4882532 = r4882519 ? r4882531 : r4882517;
        double r4882533 = r4882507 ? r4882517 : r4882532;
        return r4882533;
}

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 < -11471.638860480614 or 10055.66846222333 < 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(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)}\]
    3. Simplified0.0

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

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

    if -11471.638860480614 < x < 10055.66846222333

    1. Initial program 0.1

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

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

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

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

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

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

Reproduce

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