Average Error: 44.1 → 11.1
Time: 21.7s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 0.03274390987930671931271930930051894392818:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b, b \cdot b + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)\right)}}{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 0.03274390987930671931271930930051894392818:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b, b \cdot b + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)\right)}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2192169 = b;
        double r2192170 = -r2192169;
        double r2192171 = r2192169 * r2192169;
        double r2192172 = 4.0;
        double r2192173 = a;
        double r2192174 = r2192172 * r2192173;
        double r2192175 = c;
        double r2192176 = r2192174 * r2192175;
        double r2192177 = r2192171 - r2192176;
        double r2192178 = sqrt(r2192177);
        double r2192179 = r2192170 + r2192178;
        double r2192180 = 2.0;
        double r2192181 = r2192180 * r2192173;
        double r2192182 = r2192179 / r2192181;
        return r2192182;
}

double f(double a, double b, double c) {
        double r2192183 = b;
        double r2192184 = 0.03274390987930672;
        bool r2192185 = r2192183 <= r2192184;
        double r2192186 = r2192183 * r2192183;
        double r2192187 = 4.0;
        double r2192188 = c;
        double r2192189 = a;
        double r2192190 = r2192188 * r2192189;
        double r2192191 = r2192187 * r2192190;
        double r2192192 = r2192186 - r2192191;
        double r2192193 = sqrt(r2192192);
        double r2192194 = r2192192 * r2192193;
        double r2192195 = r2192186 * r2192183;
        double r2192196 = r2192194 - r2192195;
        double r2192197 = r2192186 + r2192192;
        double r2192198 = fma(r2192193, r2192183, r2192197);
        double r2192199 = r2192196 / r2192198;
        double r2192200 = 2.0;
        double r2192201 = r2192199 / r2192200;
        double r2192202 = r2192201 / r2192189;
        double r2192203 = -1.0;
        double r2192204 = r2192188 / r2192183;
        double r2192205 = r2192203 * r2192204;
        double r2192206 = r2192185 ? r2192202 : r2192205;
        return r2192206;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 22.5

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

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

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

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

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

    if 0.03274390987930672 < b

    1. Initial program 47.0

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

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

      \[\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 0.03274390987930671931271930930051894392818:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}, b, b \cdot b + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)\right)}}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 +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.0 a) c)))) (* 2.0 a)))