Average Error: 14.6 → 0.1
Time: 16.0s
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 r1770788 = 1.0;
        double r1770789 = x;
        double r1770790 = r1770789 + r1770788;
        double r1770791 = r1770788 / r1770790;
        double r1770792 = r1770788 / r1770789;
        double r1770793 = r1770791 - r1770792;
        return r1770793;
}

double f(double x) {
        double r1770794 = x;
        double r1770795 = -1.9941623063372853e+44;
        bool r1770796 = r1770794 <= r1770795;
        double r1770797 = 1.0;
        double r1770798 = r1770794 * r1770794;
        double r1770799 = r1770798 * r1770794;
        double r1770800 = r1770797 / r1770799;
        double r1770801 = r1770798 * r1770798;
        double r1770802 = r1770797 / r1770801;
        double r1770803 = r1770797 / r1770794;
        double r1770804 = r1770803 / r1770794;
        double r1770805 = r1770802 + r1770804;
        double r1770806 = r1770800 - r1770805;
        double r1770807 = 158565.28261171645;
        bool r1770808 = r1770794 <= r1770807;
        double r1770809 = r1770797 - r1770794;
        double r1770810 = r1770809 * r1770809;
        double r1770811 = r1770801 - r1770810;
        double r1770812 = -r1770811;
        double r1770813 = fma(r1770798, r1770798, r1770794);
        double r1770814 = -1.0;
        double r1770815 = fma(r1770794, r1770794, r1770814);
        double r1770816 = r1770794 + r1770815;
        double r1770817 = r1770813 * r1770816;
        double r1770818 = r1770812 / r1770817;
        double r1770819 = r1770808 ? r1770818 : r1770806;
        double r1770820 = r1770796 ? r1770806 : r1770819;
        return r1770820;
}

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. Using strategy rm
    11. Applied pow150.3

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

      \[\leadsto \frac{-1 - \left(x - x\right)}{\left(x \cdot x\right) \cdot \left(\color{blue}{{x}^{1}} \cdot {x}^{1}\right) + x} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)\]
    13. Applied pow-prod-up50.3

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

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

      \[\leadsto \frac{-1 - \left(x - x\right)}{\left(\color{blue}{{x}^{1}} \cdot {x}^{1}\right) \cdot {x}^{\left(1 + 1\right)} + x} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)\]
    16. Applied pow-prod-up50.3

      \[\leadsto \frac{-1 - \left(x - x\right)}{\color{blue}{{x}^{\left(1 + 1\right)}} \cdot {x}^{\left(1 + 1\right)} + x} \cdot \left(x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)\right)\]
    17. Applied pow-prod-up50.2

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot \left(x \cdot x\right)} - \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)))