Average Error: 29.2 → 0.3
Time: 22.1s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -254622.2966043480264488607645034790039062 \lor \neg \left(x \le 116203.3199069337861146777868270874023438\right):\\ \;\;\;\;-\left(\left(\log \left(e^{\frac{1}{x \cdot x}}\right) + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{x \cdot x - 1 \cdot 1}, x - 1, \frac{\frac{-1}{\mathsf{fma}\left(x, x, 1 \cdot \left(1 - x\right)\right)}}{\frac{x - 1}{{x}^{3} + {1}^{3}}}\right) + \frac{1}{\frac{x - 1}{{x}^{3} + {1}^{3}}} \cdot \left(\frac{-1}{\mathsf{fma}\left(x, x, 1 \cdot \left(1 - x\right)\right)} + \frac{1}{\mathsf{fma}\left(x, x, 1 \cdot \left(1 - x\right)\right)}\right)\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -254622.2966043480264488607645034790039062 \lor \neg \left(x \le 116203.3199069337861146777868270874023438\right):\\
\;\;\;\;-\left(\left(\log \left(e^{\frac{1}{x \cdot x}}\right) + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r98952 = x;
        double r98953 = 1.0;
        double r98954 = r98952 + r98953;
        double r98955 = r98952 / r98954;
        double r98956 = r98952 - r98953;
        double r98957 = r98954 / r98956;
        double r98958 = r98955 - r98957;
        return r98958;
}

double f(double x) {
        double r98959 = x;
        double r98960 = -254622.29660434803;
        bool r98961 = r98959 <= r98960;
        double r98962 = 116203.31990693379;
        bool r98963 = r98959 <= r98962;
        double r98964 = !r98963;
        bool r98965 = r98961 || r98964;
        double r98966 = 1.0;
        double r98967 = r98959 * r98959;
        double r98968 = r98966 / r98967;
        double r98969 = exp(r98968);
        double r98970 = log(r98969);
        double r98971 = 3.0;
        double r98972 = r98971 / r98959;
        double r98973 = r98970 + r98972;
        double r98974 = 3.0;
        double r98975 = pow(r98959, r98974);
        double r98976 = r98971 / r98975;
        double r98977 = r98973 + r98976;
        double r98978 = -r98977;
        double r98979 = r98966 * r98966;
        double r98980 = r98967 - r98979;
        double r98981 = r98959 / r98980;
        double r98982 = r98959 - r98966;
        double r98983 = -1.0;
        double r98984 = r98966 - r98959;
        double r98985 = r98966 * r98984;
        double r98986 = fma(r98959, r98959, r98985);
        double r98987 = r98983 / r98986;
        double r98988 = pow(r98966, r98974);
        double r98989 = r98975 + r98988;
        double r98990 = r98982 / r98989;
        double r98991 = r98987 / r98990;
        double r98992 = fma(r98981, r98982, r98991);
        double r98993 = 1.0;
        double r98994 = r98993 / r98990;
        double r98995 = r98993 / r98986;
        double r98996 = r98987 + r98995;
        double r98997 = r98994 * r98996;
        double r98998 = r98992 + r98997;
        double r98999 = r98965 ? r98978 : r98998;
        return r98999;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -254622.29660434803 or 116203.31990693379 < 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(\left(\frac{1}{x \cdot x} + \frac{3}{x}\right) + \frac{3}{{x}^{3}}\right)}\]
    4. Using strategy rm
    5. Applied add-log-exp0.5

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

    if -254622.29660434803 < x < 116203.31990693379

    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 flip3-+0.1

      \[\leadsto \frac{x}{x + 1} - \frac{1}{\frac{x - 1}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}}}\]
    6. Applied associate-/r/0.1

      \[\leadsto \frac{x}{x + 1} - \frac{1}{\color{blue}{\frac{x - 1}{{x}^{3} + {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)}}\]
    7. Applied add-cube-cbrt0.1

      \[\leadsto \frac{x}{x + 1} - \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{x - 1}{{x}^{3} + {1}^{3}} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)}\]
    8. Applied times-frac0.1

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{x - 1}{{x}^{3} + {1}^{3}}} \cdot \frac{\sqrt[3]{1}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}\]
    9. Applied flip-+0.2

      \[\leadsto \frac{x}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}} - \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{x - 1}{{x}^{3} + {1}^{3}}} \cdot \frac{\sqrt[3]{1}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}\]
    10. Applied associate-/r/0.1

      \[\leadsto \color{blue}{\frac{x}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{x - 1}{{x}^{3} + {1}^{3}}} \cdot \frac{\sqrt[3]{1}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}\]
    11. Applied prod-diff0.1

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

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

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

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

Reproduce

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