Average Error: 29.4 → 0.2
Time: 6.7s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -14610.34704770997814193833619356155395508 \lor \neg \left(x \le 11258.21718550441983097698539495468139648\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 -14610.34704770997814193833619356155395508 \lor \neg \left(x \le 11258.21718550441983097698539495468139648\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 r135944 = x;
        double r135945 = 1.0;
        double r135946 = r135944 + r135945;
        double r135947 = r135944 / r135946;
        double r135948 = r135944 - r135945;
        double r135949 = r135946 / r135948;
        double r135950 = r135947 - r135949;
        return r135950;
}

double f(double x) {
        double r135951 = x;
        double r135952 = -14610.347047709978;
        bool r135953 = r135951 <= r135952;
        double r135954 = 11258.21718550442;
        bool r135955 = r135951 <= r135954;
        double r135956 = !r135955;
        bool r135957 = r135953 || r135956;
        double r135958 = 1.0;
        double r135959 = -r135958;
        double r135960 = 2.0;
        double r135961 = pow(r135951, r135960);
        double r135962 = r135959 / r135961;
        double r135963 = 3.0;
        double r135964 = 1.0;
        double r135965 = r135964 / r135951;
        double r135966 = 3.0;
        double r135967 = pow(r135951, r135966);
        double r135968 = r135964 / r135967;
        double r135969 = r135963 * r135968;
        double r135970 = fma(r135963, r135965, r135969);
        double r135971 = r135962 - r135970;
        double r135972 = r135951 - r135958;
        double r135973 = r135951 * r135972;
        double r135974 = r135951 + r135958;
        double r135975 = r135974 * r135974;
        double r135976 = r135973 - r135975;
        double r135977 = r135951 * r135951;
        double r135978 = r135958 * r135958;
        double r135979 = r135977 - r135978;
        double r135980 = r135976 / r135979;
        double r135981 = exp(r135980);
        double r135982 = log(r135981);
        double r135983 = r135957 ? r135971 : r135982;
        return r135983;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -14610.347047709978 or 11258.21718550442 < x

    1. Initial program 59.2

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

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

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

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

      \[\leadsto \log \color{blue}{\left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\]
    7. Taylor expanded around inf 0.4

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

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

    if -14610.347047709978 < x < 11258.21718550442

    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 -14610.34704770997814193833619356155395508 \lor \neg \left(x \le 11258.21718550441983097698539495468139648\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 2020001 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  :precision binary64
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))