Average Error: 29.2 → 0.1
Time: 4.9s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -10838.2093226929009688319638371467590332 \lor \neg \left(x \le 8787.971449491997191216796636581420898438\right):\\ \;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x}{x + 1}}\right) - \frac{1}{\frac{x - 1}{x + 1}}\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -10838.2093226929009688319638371467590332 \lor \neg \left(x \le 8787.971449491997191216796636581420898438\right):\\
\;\;\;\;\left(\frac{-1}{{x}^{2}} - \frac{3}{x}\right) - \frac{3}{{x}^{3}}\\

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

\end{array}
double f(double x) {
        double r111592 = x;
        double r111593 = 1.0;
        double r111594 = r111592 + r111593;
        double r111595 = r111592 / r111594;
        double r111596 = r111592 - r111593;
        double r111597 = r111594 / r111596;
        double r111598 = r111595 - r111597;
        return r111598;
}

double f(double x) {
        double r111599 = x;
        double r111600 = -10838.209322692901;
        bool r111601 = r111599 <= r111600;
        double r111602 = 8787.971449491997;
        bool r111603 = r111599 <= r111602;
        double r111604 = !r111603;
        bool r111605 = r111601 || r111604;
        double r111606 = 1.0;
        double r111607 = -r111606;
        double r111608 = 2.0;
        double r111609 = pow(r111599, r111608);
        double r111610 = r111607 / r111609;
        double r111611 = 3.0;
        double r111612 = r111611 / r111599;
        double r111613 = r111610 - r111612;
        double r111614 = 3.0;
        double r111615 = pow(r111599, r111614);
        double r111616 = r111611 / r111615;
        double r111617 = r111613 - r111616;
        double r111618 = r111599 + r111606;
        double r111619 = r111599 / r111618;
        double r111620 = exp(r111619);
        double r111621 = log(r111620);
        double r111622 = 1.0;
        double r111623 = r111599 - r111606;
        double r111624 = r111623 / r111618;
        double r111625 = r111622 / r111624;
        double r111626 = r111621 - r111625;
        double r111627 = r111605 ? r111617 : r111626;
        return r111627;
}

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 < -10838.209322692901 or 8787.971449491997 < x

    1. Initial program 59.4

      \[\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 -10838.209322692901 < x < 8787.971449491997

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{1}{\frac{x - 1}{x + 1}}}\]
    4. Using strategy rm
    5. Applied add-log-exp0.1

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

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

Reproduce

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