Average Error: 29.3 → 0.1
Time: 5.4s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12729.812151040191 \lor \neg \left(x \le 10297.87902655745\right):\\ \;\;\;\;\frac{-1}{{x}^{2}} - \mathsf{fma}\left(3, \frac{1}{{x}^{3}}, \frac{3}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{x \cdot x - 1 \cdot 1}, x - 1, -\left(x + 1\right) \cdot \frac{x + 1}{x \cdot x - 1 \cdot 1}\right) + \frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(-\left(x + 1\right)\right) + \left(x + 1\right)\right)\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -12729.812151040191 \lor \neg \left(x \le 10297.87902655745\right):\\
\;\;\;\;\frac{-1}{{x}^{2}} - \mathsf{fma}\left(3, \frac{1}{{x}^{3}}, \frac{3}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{x \cdot x - 1 \cdot 1}, x - 1, -\left(x + 1\right) \cdot \frac{x + 1}{x \cdot x - 1 \cdot 1}\right) + \frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(-\left(x + 1\right)\right) + \left(x + 1\right)\right)\\

\end{array}
double f(double x) {
        double r104053 = x;
        double r104054 = 1.0;
        double r104055 = r104053 + r104054;
        double r104056 = r104053 / r104055;
        double r104057 = r104053 - r104054;
        double r104058 = r104055 / r104057;
        double r104059 = r104056 - r104058;
        return r104059;
}

double f(double x) {
        double r104060 = x;
        double r104061 = -12729.81215104019;
        bool r104062 = r104060 <= r104061;
        double r104063 = 10297.87902655745;
        bool r104064 = r104060 <= r104063;
        double r104065 = !r104064;
        bool r104066 = r104062 || r104065;
        double r104067 = 1.0;
        double r104068 = -r104067;
        double r104069 = 2.0;
        double r104070 = pow(r104060, r104069);
        double r104071 = r104068 / r104070;
        double r104072 = 3.0;
        double r104073 = 1.0;
        double r104074 = 3.0;
        double r104075 = pow(r104060, r104074);
        double r104076 = r104073 / r104075;
        double r104077 = r104072 / r104060;
        double r104078 = fma(r104072, r104076, r104077);
        double r104079 = r104071 - r104078;
        double r104080 = r104060 * r104060;
        double r104081 = r104067 * r104067;
        double r104082 = r104080 - r104081;
        double r104083 = r104060 / r104082;
        double r104084 = r104060 - r104067;
        double r104085 = r104060 + r104067;
        double r104086 = r104085 / r104082;
        double r104087 = r104085 * r104086;
        double r104088 = -r104087;
        double r104089 = fma(r104083, r104084, r104088);
        double r104090 = -r104085;
        double r104091 = r104090 + r104085;
        double r104092 = r104086 * r104091;
        double r104093 = r104089 + r104092;
        double r104094 = r104066 ? r104079 : r104093;
        return r104094;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -12729.81215104019 or 10297.87902655745 < x

    1. Initial program 59.5

      \[\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)}\]
    4. Taylor expanded around 0 0.3

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

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

    if -12729.81215104019 < x < 10297.87902655745

    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}{x + 1} - \frac{x + 1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.1

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

      \[\leadsto \frac{x}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    6. 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 \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    7. Applied prod-diff0.1

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

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

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

Reproduce

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