Average Error: 33.8 → 6.7
Time: 4.4s
Precision: 64
\[\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 -7.70031330541463201 \cdot 10^{138}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.95103770532986732 \cdot 10^{-253}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.18338381295531773 \cdot 10^{98}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \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 -7.70031330541463201 \cdot 10^{138}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

\mathbf{elif}\;b \le -3.95103770532986732 \cdot 10^{-253}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\mathbf{elif}\;b \le 4.18338381295531773 \cdot 10^{98}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r51025 = b;
        double r51026 = -r51025;
        double r51027 = r51025 * r51025;
        double r51028 = 4.0;
        double r51029 = a;
        double r51030 = r51028 * r51029;
        double r51031 = c;
        double r51032 = r51030 * r51031;
        double r51033 = r51027 - r51032;
        double r51034 = sqrt(r51033);
        double r51035 = r51026 + r51034;
        double r51036 = 2.0;
        double r51037 = r51036 * r51029;
        double r51038 = r51035 / r51037;
        return r51038;
}

double f(double a, double b, double c) {
        double r51039 = b;
        double r51040 = -7.700313305414632e+138;
        bool r51041 = r51039 <= r51040;
        double r51042 = 1.0;
        double r51043 = c;
        double r51044 = r51043 / r51039;
        double r51045 = a;
        double r51046 = r51039 / r51045;
        double r51047 = r51044 - r51046;
        double r51048 = r51042 * r51047;
        double r51049 = -3.9510377053298673e-253;
        bool r51050 = r51039 <= r51049;
        double r51051 = -r51039;
        double r51052 = r51039 * r51039;
        double r51053 = 4.0;
        double r51054 = r51053 * r51045;
        double r51055 = r51054 * r51043;
        double r51056 = r51052 - r51055;
        double r51057 = sqrt(r51056);
        double r51058 = r51051 + r51057;
        double r51059 = 2.0;
        double r51060 = r51059 * r51045;
        double r51061 = r51058 / r51060;
        double r51062 = 4.183383812955318e+98;
        bool r51063 = r51039 <= r51062;
        double r51064 = r51059 * r51043;
        double r51065 = r51051 - r51057;
        double r51066 = r51064 / r51065;
        double r51067 = -1.0;
        double r51068 = r51067 * r51044;
        double r51069 = r51063 ? r51066 : r51068;
        double r51070 = r51050 ? r51061 : r51069;
        double r51071 = r51041 ? r51048 : r51070;
        return r51071;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -7.700313305414632e+138

    1. Initial program 57.3

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified2.9

      \[\leadsto \color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\]

    if -7.700313305414632e+138 < b < -3.9510377053298673e-253

    1. Initial program 8.0

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

    if -3.9510377053298673e-253 < b < 4.183383812955318e+98

    1. Initial program 29.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 clear-num29.9

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

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}\]
    6. Applied associate-/r/30.0

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    7. Applied associate-/r*30.0

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{2 \cdot a}{\left(-b\right) \cdot \left(-b\right) - \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) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    8. Simplified15.8

      \[\leadsto \frac{\color{blue}{\frac{\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)}{2 \cdot a}}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\]
    9. Taylor expanded around 0 9.8

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

    if 4.183383812955318e+98 < b

    1. Initial program 59.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.70031330541463201 \cdot 10^{138}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.95103770532986732 \cdot 10^{-253}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.18338381295531773 \cdot 10^{98}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020065 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))