Average Error: 14.6 → 0.1
Time: 15.4s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.9941623063372853 \cdot 10^{+44}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot x} - \left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{1}{x}}{x}\right)\\ \mathbf{elif}\;x \le 158565.28261171645:\\ \;\;\;\;\frac{-\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(1 - x\right) \cdot \left(1 - x\right)\right)}{\mathsf{fma}\left(x \cdot x, x \cdot x, x\right) \cdot \left(x + \mathsf{fma}\left(x, x, -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot x} - \left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{1}{x}}{x}\right)\\ \end{array}\]
\frac{1}{x + 1} - \frac{1}{x}
\begin{array}{l}
\mathbf{if}\;x \le -1.9941623063372853 \cdot 10^{+44}:\\
\;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot x} - \left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{1}{x}}{x}\right)\\

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

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

\end{array}
double f(double x) {
        double r1873780 = 1.0;
        double r1873781 = x;
        double r1873782 = r1873781 + r1873780;
        double r1873783 = r1873780 / r1873782;
        double r1873784 = r1873780 / r1873781;
        double r1873785 = r1873783 - r1873784;
        return r1873785;
}

double f(double x) {
        double r1873786 = x;
        double r1873787 = -1.9941623063372853e+44;
        bool r1873788 = r1873786 <= r1873787;
        double r1873789 = 1.0;
        double r1873790 = r1873786 * r1873786;
        double r1873791 = r1873790 * r1873786;
        double r1873792 = r1873789 / r1873791;
        double r1873793 = r1873790 * r1873790;
        double r1873794 = r1873789 / r1873793;
        double r1873795 = r1873789 / r1873786;
        double r1873796 = r1873795 / r1873786;
        double r1873797 = r1873794 + r1873796;
        double r1873798 = r1873792 - r1873797;
        double r1873799 = 158565.28261171645;
        bool r1873800 = r1873786 <= r1873799;
        double r1873801 = r1873789 - r1873786;
        double r1873802 = r1873801 * r1873801;
        double r1873803 = r1873793 - r1873802;
        double r1873804 = -r1873803;
        double r1873805 = fma(r1873790, r1873790, r1873786);
        double r1873806 = -1.0;
        double r1873807 = fma(r1873786, r1873786, r1873806);
        double r1873808 = r1873786 + r1873807;
        double r1873809 = r1873805 * r1873808;
        double r1873810 = r1873804 / r1873809;
        double r1873811 = r1873800 ? r1873810 : r1873798;
        double r1873812 = r1873788 ? r1873798 : r1873811;
        return r1873812;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9941623063372853e+44 or 158565.28261171645 < x

    1. Initial program 27.7

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

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

      \[\leadsto \frac{\color{blue}{x + \left(-1 - x\right)}}{\left(x + 1\right) \cdot x}\]
    5. Using strategy rm
    6. Applied flip3-+60.7

      \[\leadsto \frac{x + \left(-1 - x\right)}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}} \cdot x}\]
    7. Applied associate-*l/60.7

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

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

      \[\leadsto \color{blue}{\frac{-1 - \left(x - x\right)}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + x}} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)\]
    10. Taylor expanded around inf 0.7

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

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

    if -1.9941623063372853e+44 < x < 158565.28261171645

    1. Initial program 3.9

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

      \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
    4. Simplified3.2

      \[\leadsto \frac{\color{blue}{x + \left(-1 - x\right)}}{\left(x + 1\right) \cdot x}\]
    5. Using strategy rm
    6. Applied flip3-+3.2

      \[\leadsto \frac{x + \left(-1 - x\right)}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}} \cdot x}\]
    7. Applied associate-*l/3.2

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.9941623063372853 \cdot 10^{+44}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot x} - \left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{1}{x}}{x}\right)\\ \mathbf{elif}\;x \le 158565.28261171645:\\ \;\;\;\;\frac{-\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(1 - x\right) \cdot \left(1 - x\right)\right)}{\mathsf{fma}\left(x \cdot x, x \cdot x, x\right) \cdot \left(x + \mathsf{fma}\left(x, x, -1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot x} - \left(\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} + \frac{\frac{1}{x}}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  (- (/ 1 (+ x 1)) (/ 1 x)))