Average Error: 43.9 → 11.1
Time: 7.5s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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 2.56800976414688911 \cdot 10^{-4}:\\ \;\;\;\;\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 2.56800976414688911 \cdot 10^{-4}:\\
\;\;\;\;\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 r31950 = b;
        double r31951 = -r31950;
        double r31952 = r31950 * r31950;
        double r31953 = 4.0;
        double r31954 = a;
        double r31955 = r31953 * r31954;
        double r31956 = c;
        double r31957 = r31955 * r31956;
        double r31958 = r31952 - r31957;
        double r31959 = sqrt(r31958);
        double r31960 = r31951 + r31959;
        double r31961 = 2.0;
        double r31962 = r31961 * r31954;
        double r31963 = r31960 / r31962;
        return r31963;
}

double f(double a, double b, double c) {
        double r31964 = b;
        double r31965 = 0.0002568009764146889;
        bool r31966 = r31964 <= r31965;
        double r31967 = r31964 * r31964;
        double r31968 = 4.0;
        double r31969 = a;
        double r31970 = r31968 * r31969;
        double r31971 = c;
        double r31972 = r31970 * r31971;
        double r31973 = fma(r31964, r31964, r31972);
        double r31974 = r31967 - r31973;
        double r31975 = r31967 - r31972;
        double r31976 = sqrt(r31975);
        double r31977 = r31976 + r31964;
        double r31978 = r31974 / r31977;
        double r31979 = 2.0;
        double r31980 = r31978 / r31979;
        double r31981 = r31980 / r31969;
        double r31982 = -1.0;
        double r31983 = r31971 / r31964;
        double r31984 = r31982 * r31983;
        double r31985 = r31966 ? r31981 : r31984;
        return r31985;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 19.5

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

      \[\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--19.6

      \[\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. Simplified18.8

      \[\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 0.0002568009764146889 < b

    1. Initial program 45.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 2.56800976414688911 \cdot 10^{-4}:\\ \;\;\;\;\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 2020042 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))