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

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

\end{array}
double f(double x) {
        double r105853 = x;
        double r105854 = 1.0;
        double r105855 = r105853 + r105854;
        double r105856 = r105853 / r105855;
        double r105857 = r105853 - r105854;
        double r105858 = r105855 / r105857;
        double r105859 = r105856 - r105858;
        return r105859;
}

double f(double x) {
        double r105860 = x;
        double r105861 = -5227973778324721.0;
        double r105862 = 549755813888.0;
        double r105863 = r105861 / r105862;
        bool r105864 = r105860 <= r105863;
        double r105865 = 1520701503786563.0;
        double r105866 = 137438953472.0;
        double r105867 = r105865 / r105866;
        bool r105868 = r105860 <= r105867;
        double r105869 = !r105868;
        bool r105870 = r105864 || r105869;
        double r105871 = 1.0;
        double r105872 = -r105871;
        double r105873 = 2.0;
        double r105874 = pow(r105860, r105873);
        double r105875 = r105872 / r105874;
        double r105876 = 3.0;
        double r105877 = r105876 / r105860;
        double r105878 = r105875 - r105877;
        double r105879 = 3.0;
        double r105880 = pow(r105860, r105879);
        double r105881 = r105876 / r105880;
        double r105882 = r105878 - r105881;
        double r105883 = r105860 + r105871;
        double r105884 = r105860 / r105883;
        double r105885 = 1.0;
        double r105886 = r105860 - r105871;
        double r105887 = r105885 / r105886;
        double r105888 = r105883 * r105887;
        double r105889 = exp(r105888);
        double r105890 = log(r105889);
        double r105891 = r105884 - r105890;
        double r105892 = r105870 ? r105882 : r105891;
        return r105892;
}

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 < -9509.628904788262 or 11064.559685376029 < x

    1. Initial program 59.2

      \[\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 -9509.628904788262 < x < 11064.559685376029

    1. Initial program 0.1

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

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

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

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

Reproduce

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