Average Error: 34.0 → 12.4
Time: 5.6s
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 -1.64064137297236348 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.5846768506177574 \cdot 10^{-31}:\\ \;\;\;\;\frac{\frac{4}{\frac{\left({b}^{2} - {b}^{2}\right) + 4 \cdot \left(a \cdot c\right)}{a \cdot c}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{2 \cdot 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 -1.64064137297236348 \cdot 10^{109}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r61039 = b;
        double r61040 = -r61039;
        double r61041 = r61039 * r61039;
        double r61042 = 4.0;
        double r61043 = a;
        double r61044 = r61042 * r61043;
        double r61045 = c;
        double r61046 = r61044 * r61045;
        double r61047 = r61041 - r61046;
        double r61048 = sqrt(r61047);
        double r61049 = r61040 + r61048;
        double r61050 = 2.0;
        double r61051 = r61050 * r61043;
        double r61052 = r61049 / r61051;
        return r61052;
}

double f(double a, double b, double c) {
        double r61053 = b;
        double r61054 = -1.6406413729723635e+109;
        bool r61055 = r61053 <= r61054;
        double r61056 = 1.0;
        double r61057 = c;
        double r61058 = r61057 / r61053;
        double r61059 = a;
        double r61060 = r61053 / r61059;
        double r61061 = r61058 - r61060;
        double r61062 = r61056 * r61061;
        double r61063 = 1.5846768506177574e-31;
        bool r61064 = r61053 <= r61063;
        double r61065 = 4.0;
        double r61066 = 2.0;
        double r61067 = pow(r61053, r61066);
        double r61068 = r61067 - r61067;
        double r61069 = r61059 * r61057;
        double r61070 = r61065 * r61069;
        double r61071 = r61068 + r61070;
        double r61072 = r61071 / r61069;
        double r61073 = r61065 / r61072;
        double r61074 = -r61053;
        double r61075 = r61053 * r61053;
        double r61076 = r61065 * r61059;
        double r61077 = r61076 * r61057;
        double r61078 = r61075 - r61077;
        double r61079 = sqrt(r61078);
        double r61080 = r61074 + r61079;
        double r61081 = r61073 * r61080;
        double r61082 = 2.0;
        double r61083 = r61082 * r61059;
        double r61084 = r61081 / r61083;
        double r61085 = -1.0;
        double r61086 = r61085 * r61058;
        double r61087 = r61064 ? r61084 : r61086;
        double r61088 = r61055 ? r61062 : r61087;
        return r61088;
}

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

    1. Initial program 49.5

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

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

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

    if -1.6406413729723635e+109 < b < 1.5846768506177574e-31

    1. Initial program 14.5

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

      \[\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. Simplified28.6

      \[\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 flip--31.5

      \[\leadsto \frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\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}\]
    7. Applied associate-/r/31.6

      \[\leadsto \frac{\color{blue}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\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)}}{2 \cdot a}\]
    8. Simplified18.6

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

    if 1.5846768506177574e-31 < b

    1. Initial program 54.3

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

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

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

Reproduce

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