Average Error: 43.6 → 10.3
Time: 46.7s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -2.341267908031465 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right) \cdot \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} + b, \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \frac{c \cdot a}{b}\right) \cdot \frac{\frac{1}{2}}{a}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -2.341267908031465 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right) \cdot \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} + b, \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}, b \cdot b\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot \frac{c \cdot a}{b}\right) \cdot \frac{\frac{1}{2}}{a}\\

\end{array}
double f(double a, double b, double c) {
        double r2299837 = b;
        double r2299838 = -r2299837;
        double r2299839 = r2299837 * r2299837;
        double r2299840 = 4.0;
        double r2299841 = a;
        double r2299842 = r2299840 * r2299841;
        double r2299843 = c;
        double r2299844 = r2299842 * r2299843;
        double r2299845 = r2299839 - r2299844;
        double r2299846 = sqrt(r2299845);
        double r2299847 = r2299838 + r2299846;
        double r2299848 = 2.0;
        double r2299849 = r2299848 * r2299841;
        double r2299850 = r2299847 / r2299849;
        return r2299850;
}

double f(double a, double b, double c) {
        double r2299851 = b;
        double r2299852 = r2299851 * r2299851;
        double r2299853 = 4.0;
        double r2299854 = a;
        double r2299855 = r2299853 * r2299854;
        double r2299856 = c;
        double r2299857 = r2299855 * r2299856;
        double r2299858 = r2299852 - r2299857;
        double r2299859 = sqrt(r2299858);
        double r2299860 = -r2299851;
        double r2299861 = r2299859 + r2299860;
        double r2299862 = 2.0;
        double r2299863 = r2299862 * r2299854;
        double r2299864 = r2299861 / r2299863;
        double r2299865 = -2.341267908031465e-05;
        bool r2299866 = r2299864 <= r2299865;
        double r2299867 = -4.0;
        double r2299868 = r2299867 * r2299854;
        double r2299869 = r2299856 * r2299868;
        double r2299870 = fma(r2299851, r2299851, r2299869);
        double r2299871 = sqrt(r2299870);
        double r2299872 = r2299870 * r2299871;
        double r2299873 = r2299851 * r2299852;
        double r2299874 = r2299872 - r2299873;
        double r2299875 = r2299871 + r2299851;
        double r2299876 = fma(r2299875, r2299871, r2299852);
        double r2299877 = r2299874 / r2299876;
        double r2299878 = r2299877 / r2299863;
        double r2299879 = -2.0;
        double r2299880 = r2299856 * r2299854;
        double r2299881 = r2299880 / r2299851;
        double r2299882 = r2299879 * r2299881;
        double r2299883 = 0.5;
        double r2299884 = r2299883 / r2299854;
        double r2299885 = r2299882 * r2299884;
        double r2299886 = r2299866 ? r2299878 : r2299885;
        return r2299886;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -2.341267908031465e-05

    1. Initial program 20.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+20.8

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{3} + {\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}^{3}}{\left(-b\right) \cdot \left(-b\right) + \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    4. Simplified20.3

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} \cdot \mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right) - \left(b \cdot b\right) \cdot b}}{\left(-b\right) \cdot \left(-b\right) + \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    5. Simplified20.3

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} \cdot \mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right) - \left(b \cdot b\right) \cdot b}{\color{blue}{\mathsf{fma}\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}, \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}, b \cdot b\right)}}}{2 \cdot a}\]

    if -2.341267908031465e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 51.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 6.9

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied div-inv7.0

      \[\leadsto \color{blue}{\left(-2 \cdot \frac{a \cdot c}{b}\right) \cdot \frac{1}{2 \cdot a}}\]
    5. Simplified7.0

      \[\leadsto \left(-2 \cdot \frac{a \cdot c}{b}\right) \cdot \color{blue}{\frac{\frac{1}{2}}{a}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -2.341267908031465 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right) \cdot \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)} + b, \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \frac{c \cdot a}{b}\right) \cdot \frac{\frac{1}{2}}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019144 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))