Average Error: 33.9 → 6.9
Time: 4.8s
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 -5.58543573862810322 \cdot 10^{150}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.3730540219645598 \cdot 10^{-278}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{elif}\;b \le 1.55563303224959 \cdot 10^{106}:\\ \;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\ \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 -5.58543573862810322 \cdot 10^{150}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 1.55563303224959 \cdot 10^{106}:\\
\;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\

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

\end{array}
double f(double a, double b, double c) {
        double r50175 = b;
        double r50176 = -r50175;
        double r50177 = r50175 * r50175;
        double r50178 = 4.0;
        double r50179 = a;
        double r50180 = r50178 * r50179;
        double r50181 = c;
        double r50182 = r50180 * r50181;
        double r50183 = r50177 - r50182;
        double r50184 = sqrt(r50183);
        double r50185 = r50176 + r50184;
        double r50186 = 2.0;
        double r50187 = r50186 * r50179;
        double r50188 = r50185 / r50187;
        return r50188;
}

double f(double a, double b, double c) {
        double r50189 = b;
        double r50190 = -5.585435738628103e+150;
        bool r50191 = r50189 <= r50190;
        double r50192 = 1.0;
        double r50193 = c;
        double r50194 = r50193 / r50189;
        double r50195 = a;
        double r50196 = r50189 / r50195;
        double r50197 = r50194 - r50196;
        double r50198 = r50192 * r50197;
        double r50199 = -2.3730540219645598e-278;
        bool r50200 = r50189 <= r50199;
        double r50201 = 1.0;
        double r50202 = 2.0;
        double r50203 = r50202 * r50195;
        double r50204 = -r50189;
        double r50205 = r50189 * r50189;
        double r50206 = 4.0;
        double r50207 = r50206 * r50195;
        double r50208 = r50207 * r50193;
        double r50209 = r50205 - r50208;
        double r50210 = sqrt(r50209);
        double r50211 = r50204 + r50210;
        double r50212 = r50203 / r50211;
        double r50213 = r50201 / r50212;
        double r50214 = 1.55563303224959e+106;
        bool r50215 = r50189 <= r50214;
        double r50216 = 0.5;
        double r50217 = r50216 / r50193;
        double r50218 = r50204 - r50210;
        double r50219 = r50217 * r50218;
        double r50220 = r50201 / r50219;
        double r50221 = -1.0;
        double r50222 = r50221 * r50194;
        double r50223 = r50215 ? r50220 : r50222;
        double r50224 = r50200 ? r50213 : r50223;
        double r50225 = r50191 ? r50198 : r50224;
        return r50225;
}

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 < -5.585435738628103e+150

    1. Initial program 61.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.2

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

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

    if -5.585435738628103e+150 < b < -2.3730540219645598e-278

    1. Initial program 8.1

      \[\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-num8.3

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

    if -2.3730540219645598e-278 < b < 1.55563303224959e+106

    1. Initial program 31.3

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

      \[\leadsto \frac{\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}}}}{2 \cdot a}\]
    4. Simplified16.7

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.7

      \[\leadsto \frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    7. Applied *-un-lft-identity16.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(0 + 4 \cdot \left(a \cdot c\right)\right)}}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    8. Applied times-frac16.7

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    9. Applied associate-/l*16.9

      \[\leadsto \color{blue}{\frac{\frac{1}{1}}{\frac{2 \cdot a}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}\]
    10. Simplified16.2

      \[\leadsto \frac{\frac{1}{1}}{\color{blue}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    11. Taylor expanded around 0 9.9

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

    if 1.55563303224959e+106 < b

    1. Initial program 60.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.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.58543573862810322 \cdot 10^{150}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.3730540219645598 \cdot 10^{-278}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{elif}\;b \le 1.55563303224959 \cdot 10^{106}:\\ \;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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