Average Error: 28.5 → 16.4
Time: 8.1s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 3187.18097597923543:\\ \;\;\;\;\frac{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \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}\;b \le 3187.18097597923543:\\
\;\;\;\;\frac{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{a}\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r44855 = b;
        double r44856 = -r44855;
        double r44857 = r44855 * r44855;
        double r44858 = 4.0;
        double r44859 = a;
        double r44860 = r44858 * r44859;
        double r44861 = c;
        double r44862 = r44860 * r44861;
        double r44863 = r44857 - r44862;
        double r44864 = sqrt(r44863);
        double r44865 = r44856 + r44864;
        double r44866 = 2.0;
        double r44867 = r44866 * r44859;
        double r44868 = r44865 / r44867;
        return r44868;
}

double f(double a, double b, double c) {
        double r44869 = b;
        double r44870 = 3187.1809759792354;
        bool r44871 = r44869 <= r44870;
        double r44872 = r44869 * r44869;
        double r44873 = 4.0;
        double r44874 = a;
        double r44875 = r44873 * r44874;
        double r44876 = c;
        double r44877 = r44875 * r44876;
        double r44878 = fma(r44869, r44869, r44877);
        double r44879 = r44872 - r44878;
        double r44880 = r44872 - r44877;
        double r44881 = sqrt(r44880);
        double r44882 = r44881 + r44869;
        double r44883 = r44879 / r44882;
        double r44884 = 2.0;
        double r44885 = r44883 / r44884;
        double r44886 = r44885 / r44874;
        double r44887 = -1.0;
        double r44888 = r44876 / r44869;
        double r44889 = r44887 * r44888;
        double r44890 = r44871 ? r44886 : r44889;
        return r44890;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3187.1809759792354

    1. Initial program 18.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified18.2

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied flip--18.2

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

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

    if 3187.1809759792354 < b

    1. Initial program 37.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified37.2

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}}\]
    3. Taylor expanded around inf 15.5

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.4

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))