Average Error: 29.4 → 0.1
Time: 15.0s
Precision: 64
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -10110.88651437990483827888965606689453125:\\ \;\;\;\;\frac{-3}{\left(x \cdot x\right) \cdot x} - \left(\frac{3}{x} + \frac{1}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 16309.13855706636968534439802169799804688:\\ \;\;\;\;\log \left(e^{\frac{x \cdot \left(\left(x - 1\right) \cdot \left(x - 1\right)\right) - \left(x + 1\right) \cdot \left(\left(x + 1\right) \cdot \left(x - 1\right)\right)}{\left(\left(x - 1\right) \cdot \left(x - 1\right)\right) \cdot \left(x + 1\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{\left(x \cdot x\right) \cdot x} - \left(\frac{3}{x} + \frac{1}{x \cdot x}\right)\\ \end{array}\]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -10110.88651437990483827888965606689453125:\\
\;\;\;\;\frac{-3}{\left(x \cdot x\right) \cdot x} - \left(\frac{3}{x} + \frac{1}{x \cdot x}\right)\\

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

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

\end{array}
double f(double x) {
        double r6043870 = x;
        double r6043871 = 1.0;
        double r6043872 = r6043870 + r6043871;
        double r6043873 = r6043870 / r6043872;
        double r6043874 = r6043870 - r6043871;
        double r6043875 = r6043872 / r6043874;
        double r6043876 = r6043873 - r6043875;
        return r6043876;
}

double f(double x) {
        double r6043877 = x;
        double r6043878 = -10110.886514379905;
        bool r6043879 = r6043877 <= r6043878;
        double r6043880 = 3.0;
        double r6043881 = -r6043880;
        double r6043882 = r6043877 * r6043877;
        double r6043883 = r6043882 * r6043877;
        double r6043884 = r6043881 / r6043883;
        double r6043885 = r6043880 / r6043877;
        double r6043886 = 1.0;
        double r6043887 = r6043886 / r6043882;
        double r6043888 = r6043885 + r6043887;
        double r6043889 = r6043884 - r6043888;
        double r6043890 = 16309.13855706637;
        bool r6043891 = r6043877 <= r6043890;
        double r6043892 = r6043877 - r6043886;
        double r6043893 = r6043892 * r6043892;
        double r6043894 = r6043877 * r6043893;
        double r6043895 = r6043877 + r6043886;
        double r6043896 = r6043895 * r6043892;
        double r6043897 = r6043895 * r6043896;
        double r6043898 = r6043894 - r6043897;
        double r6043899 = r6043893 * r6043895;
        double r6043900 = r6043898 / r6043899;
        double r6043901 = exp(r6043900);
        double r6043902 = log(r6043901);
        double r6043903 = r6043891 ? r6043902 : r6043889;
        double r6043904 = r6043879 ? r6043889 : r6043903;
        return r6043904;
}

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 < -10110.886514379905 or 16309.13855706637 < x

    1. Initial program 59.3

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

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

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

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

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

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

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

    if -10110.886514379905 < x < 16309.13855706637

    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 div-inv0.1

      \[\leadsto \log \left(e^{\frac{x}{x + 1} - \color{blue}{\left(x + 1\right) \cdot \frac{1}{x - 1}}}\right)\]
    9. Using strategy rm
    10. Applied flip-+0.1

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -10110.88651437990483827888965606689453125:\\ \;\;\;\;\frac{-3}{\left(x \cdot x\right) \cdot x} - \left(\frac{3}{x} + \frac{1}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 16309.13855706636968534439802169799804688:\\ \;\;\;\;\log \left(e^{\frac{x \cdot \left(\left(x - 1\right) \cdot \left(x - 1\right)\right) - \left(x + 1\right) \cdot \left(\left(x + 1\right) \cdot \left(x - 1\right)\right)}{\left(\left(x - 1\right) \cdot \left(x - 1\right)\right) \cdot \left(x + 1\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-3}{\left(x \cdot x\right) \cdot x} - \left(\frac{3}{x} + \frac{1}{x \cdot x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))