Average Error: 34.1 → 6.7
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 -2.223763057046510327568967152287533282505 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.319380566438366601816459280349243307141 \cdot 10^{-186}:\\ \;\;\;\;\frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2} \cdot \frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{elif}\;b \le 1.458057835821772074616178333218437979276 \cdot 10^{144}:\\ \;\;\;\;\frac{\frac{c}{0.5}}{\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 -2.223763057046510327568967152287533282505 \cdot 10^{109}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 1.458057835821772074616178333218437979276 \cdot 10^{144}:\\
\;\;\;\;\frac{\frac{c}{0.5}}{\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 r50995 = b;
        double r50996 = -r50995;
        double r50997 = r50995 * r50995;
        double r50998 = 4.0;
        double r50999 = a;
        double r51000 = r50998 * r50999;
        double r51001 = c;
        double r51002 = r51000 * r51001;
        double r51003 = r50997 - r51002;
        double r51004 = sqrt(r51003);
        double r51005 = r50996 + r51004;
        double r51006 = 2.0;
        double r51007 = r51006 * r50999;
        double r51008 = r51005 / r51007;
        return r51008;
}

double f(double a, double b, double c) {
        double r51009 = b;
        double r51010 = -2.2237630570465103e+109;
        bool r51011 = r51009 <= r51010;
        double r51012 = 1.0;
        double r51013 = c;
        double r51014 = r51013 / r51009;
        double r51015 = a;
        double r51016 = r51009 / r51015;
        double r51017 = r51014 - r51016;
        double r51018 = r51012 * r51017;
        double r51019 = -3.3193805664383666e-186;
        bool r51020 = r51009 <= r51019;
        double r51021 = -r51009;
        double r51022 = r51009 * r51009;
        double r51023 = 4.0;
        double r51024 = r51023 * r51015;
        double r51025 = r51024 * r51013;
        double r51026 = r51022 - r51025;
        double r51027 = sqrt(r51026);
        double r51028 = r51021 + r51027;
        double r51029 = sqrt(r51028);
        double r51030 = 2.0;
        double r51031 = r51029 / r51030;
        double r51032 = r51029 / r51015;
        double r51033 = r51031 * r51032;
        double r51034 = 1.458057835821772e+144;
        bool r51035 = r51009 <= r51034;
        double r51036 = 0.5;
        double r51037 = r51013 / r51036;
        double r51038 = r51021 - r51027;
        double r51039 = r51037 / r51038;
        double r51040 = -1.0;
        double r51041 = r51040 * r51014;
        double r51042 = r51035 ? r51039 : r51041;
        double r51043 = r51020 ? r51033 : r51042;
        double r51044 = r51011 ? r51018 : r51043;
        return r51044;
}

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 < -2.2237630570465103e+109

    1. Initial program 48.6

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

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

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

    if -2.2237630570465103e+109 < b < -3.3193805664383666e-186

    1. Initial program 6.9

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

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

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

    if -3.3193805664383666e-186 < b < 1.458057835821772e+144

    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.5

      \[\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.1

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

      \[\leadsto \color{blue}{\frac{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}}}}}\]
    7. Simplified15.3

      \[\leadsto \frac{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)}}\]
    8. Taylor expanded around 0 10.2

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

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

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

    if 1.458057835821772e+144 < b

    1. Initial program 62.9

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

      \[\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 -2.223763057046510327568967152287533282505 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.319380566438366601816459280349243307141 \cdot 10^{-186}:\\ \;\;\;\;\frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2} \cdot \frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{elif}\;b \le 1.458057835821772074616178333218437979276 \cdot 10^{144}:\\ \;\;\;\;\frac{\frac{c}{0.5}}{\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 2020001 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))