Average Error: 34.4 → 10.0
Time: 4.7s
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 -9.91243958875386880555748684589545292526 \cdot 10^{101}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.209120745343099452134664059704875392955 \cdot 10^{-70}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - {\left(4 \cdot \left(a \cdot c\right)\right)}^{1}}}{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 -9.91243958875386880555748684589545292526 \cdot 10^{101}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r49527 = b;
        double r49528 = -r49527;
        double r49529 = r49527 * r49527;
        double r49530 = 4.0;
        double r49531 = a;
        double r49532 = r49530 * r49531;
        double r49533 = c;
        double r49534 = r49532 * r49533;
        double r49535 = r49529 - r49534;
        double r49536 = sqrt(r49535);
        double r49537 = r49528 + r49536;
        double r49538 = 2.0;
        double r49539 = r49538 * r49531;
        double r49540 = r49537 / r49539;
        return r49540;
}

double f(double a, double b, double c) {
        double r49541 = b;
        double r49542 = -9.912439588753869e+101;
        bool r49543 = r49541 <= r49542;
        double r49544 = 1.0;
        double r49545 = c;
        double r49546 = r49545 / r49541;
        double r49547 = a;
        double r49548 = r49541 / r49547;
        double r49549 = r49546 - r49548;
        double r49550 = r49544 * r49549;
        double r49551 = 1.2091207453430995e-70;
        bool r49552 = r49541 <= r49551;
        double r49553 = -r49541;
        double r49554 = r49541 * r49541;
        double r49555 = 4.0;
        double r49556 = r49547 * r49545;
        double r49557 = r49555 * r49556;
        double r49558 = 1.0;
        double r49559 = pow(r49557, r49558);
        double r49560 = r49554 - r49559;
        double r49561 = sqrt(r49560);
        double r49562 = r49553 + r49561;
        double r49563 = 2.0;
        double r49564 = r49562 / r49563;
        double r49565 = r49564 / r49547;
        double r49566 = -1.0;
        double r49567 = r49566 * r49546;
        double r49568 = r49552 ? r49565 : r49567;
        double r49569 = r49543 ? r49550 : r49568;
        return r49569;
}

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 3 regimes
  2. if b < -9.912439588753869e+101

    1. Initial program 46.9

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

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

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

    if -9.912439588753869e+101 < b < 1.2091207453430995e-70

    1. Initial program 13.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 pow113.3

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(\color{blue}{{4}^{1}} \cdot {a}^{1}\right) \cdot {c}^{1}}}{2 \cdot a}\]
    6. Applied pow-prod-down13.3

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(4 \cdot a\right)}^{1}} \cdot {c}^{1}}}{2 \cdot a}\]
    7. Applied pow-prod-down13.3

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left(4 \cdot \left(a \cdot c\right)\right)}}^{1}}}{2 \cdot a}\]
    9. Using strategy rm
    10. Applied associate-/r*13.3

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

    if 1.2091207453430995e-70 < b

    1. Initial program 53.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -9.91243958875386880555748684589545292526 \cdot 10^{101}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.209120745343099452134664059704875392955 \cdot 10^{-70}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - {\left(4 \cdot \left(a \cdot c\right)\right)}^{1}}}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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