Average Error: 14.9 → 0.1
Time: 9.8s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9124183958286494 \lor \neg \left(x \le 14237.069114952126\right):\\ \;\;\;\;\left(-\frac{2}{{x}^{6}}\right) - \left(\frac{\frac{2}{x}}{{x}^{\left(\frac{2}{2}\right)}} + \frac{2}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x - 1}
\begin{array}{l}
\mathbf{if}\;x \le -9124183958286494 \lor \neg \left(x \le 14237.069114952126\right):\\
\;\;\;\;\left(-\frac{2}{{x}^{6}}\right) - \left(\frac{\frac{2}{x}}{{x}^{\left(\frac{2}{2}\right)}} + \frac{2}{{x}^{4}}\right)\\

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

\end{array}
double f(double x) {
        double r118668 = 1.0;
        double r118669 = x;
        double r118670 = r118669 + r118668;
        double r118671 = r118668 / r118670;
        double r118672 = r118669 - r118668;
        double r118673 = r118668 / r118672;
        double r118674 = r118671 - r118673;
        return r118674;
}

double f(double x) {
        double r118675 = x;
        double r118676 = -9124183958286494.0;
        bool r118677 = r118675 <= r118676;
        double r118678 = 14237.069114952126;
        bool r118679 = r118675 <= r118678;
        double r118680 = !r118679;
        bool r118681 = r118677 || r118680;
        double r118682 = 2.0;
        double r118683 = 6.0;
        double r118684 = pow(r118675, r118683);
        double r118685 = r118682 / r118684;
        double r118686 = -r118685;
        double r118687 = r118682 / r118675;
        double r118688 = 2.0;
        double r118689 = r118688 / r118688;
        double r118690 = pow(r118675, r118689);
        double r118691 = r118687 / r118690;
        double r118692 = 4.0;
        double r118693 = pow(r118675, r118692);
        double r118694 = r118682 / r118693;
        double r118695 = r118691 + r118694;
        double r118696 = r118686 - r118695;
        double r118697 = 1.0;
        double r118698 = r118675 * r118675;
        double r118699 = r118697 * r118697;
        double r118700 = r118698 - r118699;
        double r118701 = r118697 / r118700;
        double r118702 = r118675 - r118697;
        double r118703 = r118675 + r118697;
        double r118704 = r118702 - r118703;
        double r118705 = r118701 * r118704;
        double r118706 = r118681 ? r118696 : r118705;
        return r118706;
}

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 < -9124183958286494.0 or 14237.069114952126 < x

    1. Initial program 29.7

      \[\frac{1}{x + 1} - \frac{1}{x - 1}\]
    2. Taylor expanded around inf 0.8

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

      \[\leadsto \color{blue}{\left(-\frac{2}{{x}^{6}}\right) - \left(\frac{2}{{x}^{2}} + \frac{2}{{x}^{4}}\right)}\]
    4. Using strategy rm
    5. Applied sqr-pow0.8

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

      \[\leadsto \left(-\frac{2}{{x}^{6}}\right) - \left(\color{blue}{\frac{\frac{2}{{x}^{\left(\frac{2}{2}\right)}}}{{x}^{\left(\frac{2}{2}\right)}}} + \frac{2}{{x}^{4}}\right)\]
    7. Simplified0.1

      \[\leadsto \left(-\frac{2}{{x}^{6}}\right) - \left(\frac{\color{blue}{\frac{2}{x}}}{{x}^{\left(\frac{2}{2}\right)}} + \frac{2}{{x}^{4}}\right)\]

    if -9124183958286494.0 < x < 14237.069114952126

    1. Initial program 0.7

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

      \[\leadsto \frac{1}{x + 1} - \frac{1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.7

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x - 1\right)} - \frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    7. Applied distribute-lft-out--0.0

      \[\leadsto \color{blue}{\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\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 -9124183958286494 \lor \neg \left(x \le 14237.069114952126\right):\\ \;\;\;\;\left(-\frac{2}{{x}^{6}}\right) - \left(\frac{\frac{2}{x}}{{x}^{\left(\frac{2}{2}\right)}} + \frac{2}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot x - 1 \cdot 1} \cdot \left(\left(x - 1\right) - \left(x + 1\right)\right)\\ \end{array}\]

Reproduce

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