Average Error: 28.9 → 0.2
Time: 20.2s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12332.7484463211567 \lor \neg \left(x \le 13264.4327344624\right):\\ \;\;\;\;\frac{-1}{{x}^{2}} - \mathsf{fma}\left(3, \frac{1}{x}, 3 \cdot \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{x \cdot x - 1 \cdot 1}}\right)\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -12332.7484463211567 \lor \neg \left(x \le 13264.4327344624\right):\\
\;\;\;\;\frac{-1}{{x}^{2}} - \mathsf{fma}\left(3, \frac{1}{x}, 3 \cdot \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r216081 = x;
        double r216082 = 1.0;
        double r216083 = r216081 + r216082;
        double r216084 = r216081 / r216083;
        double r216085 = r216081 - r216082;
        double r216086 = r216083 / r216085;
        double r216087 = r216084 - r216086;
        return r216087;
}

double f(double x) {
        double r216088 = x;
        double r216089 = -12332.748446321157;
        bool r216090 = r216088 <= r216089;
        double r216091 = 13264.4327344624;
        bool r216092 = r216088 <= r216091;
        double r216093 = !r216092;
        bool r216094 = r216090 || r216093;
        double r216095 = 1.0;
        double r216096 = -r216095;
        double r216097 = 2.0;
        double r216098 = pow(r216088, r216097);
        double r216099 = r216096 / r216098;
        double r216100 = 3.0;
        double r216101 = 1.0;
        double r216102 = r216101 / r216088;
        double r216103 = 3.0;
        double r216104 = pow(r216088, r216103);
        double r216105 = r216101 / r216104;
        double r216106 = r216100 * r216105;
        double r216107 = fma(r216100, r216102, r216106);
        double r216108 = r216099 - r216107;
        double r216109 = r216088 - r216095;
        double r216110 = r216088 * r216109;
        double r216111 = r216088 + r216095;
        double r216112 = r216111 * r216111;
        double r216113 = r216110 - r216112;
        double r216114 = r216088 * r216088;
        double r216115 = r216095 * r216095;
        double r216116 = r216114 - r216115;
        double r216117 = r216113 / r216116;
        double r216118 = exp(r216117);
        double r216119 = log(r216118);
        double r216120 = r216094 ? r216108 : r216119;
        return r216120;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -12332.748446321157 or 13264.4327344624 < x

    1. Initial program 59.1

      \[\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.3

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

    if -12332.748446321157 < x < 13264.4327344624

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\log \left(e^{\frac{x + 1}{x - 1}}\right)}\]
    4. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1}}\right)} - \log \left(e^{\frac{x + 1}{x - 1}}\right)\]
    5. Applied diff-log0.1

      \[\leadsto \color{blue}{\log \left(\frac{e^{\frac{x}{x + 1}}}{e^{\frac{x + 1}{x - 1}}}\right)}\]
    6. Simplified0.1

      \[\leadsto \log \color{blue}{\left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\]
    7. Using strategy rm
    8. Applied frac-sub0.1

      \[\leadsto \log \left(e^{\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)}}}\right)\]
    9. Simplified0.1

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

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

Reproduce

herbie shell --seed 2020059 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  :precision binary64
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))