Average Error: 32.8 → 10.0
Time: 18.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 -3.063397748446981 \cdot 10^{+71}:\\ \;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\ \mathbf{elif}\;b \le 3.1295384133612364 \cdot 10^{-73}:\\ \;\;\;\;\frac{\frac{1}{a} \cdot \left(\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{b} \cdot -2}{2}\\ \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 -3.063397748446981 \cdot 10^{+71}:\\
\;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r966103 = b;
        double r966104 = -r966103;
        double r966105 = r966103 * r966103;
        double r966106 = 4.0;
        double r966107 = a;
        double r966108 = r966106 * r966107;
        double r966109 = c;
        double r966110 = r966108 * r966109;
        double r966111 = r966105 - r966110;
        double r966112 = sqrt(r966111);
        double r966113 = r966104 + r966112;
        double r966114 = 2.0;
        double r966115 = r966114 * r966107;
        double r966116 = r966113 / r966115;
        return r966116;
}

double f(double a, double b, double c) {
        double r966117 = b;
        double r966118 = -3.063397748446981e+71;
        bool r966119 = r966117 <= r966118;
        double r966120 = c;
        double r966121 = r966120 / r966117;
        double r966122 = a;
        double r966123 = r966117 / r966122;
        double r966124 = r966121 - r966123;
        double r966125 = 2.0;
        double r966126 = r966124 * r966125;
        double r966127 = r966126 / r966125;
        double r966128 = 3.1295384133612364e-73;
        bool r966129 = r966117 <= r966128;
        double r966130 = 1.0;
        double r966131 = r966130 / r966122;
        double r966132 = r966117 * r966117;
        double r966133 = 4.0;
        double r966134 = r966120 * r966122;
        double r966135 = r966133 * r966134;
        double r966136 = r966132 - r966135;
        double r966137 = sqrt(r966136);
        double r966138 = r966137 - r966117;
        double r966139 = r966131 * r966138;
        double r966140 = r966139 / r966125;
        double r966141 = -2.0;
        double r966142 = r966121 * r966141;
        double r966143 = r966142 / r966125;
        double r966144 = r966129 ? r966140 : r966143;
        double r966145 = r966119 ? r966127 : r966144;
        return r966145;
}

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 < -3.063397748446981e+71

    1. Initial program 38.6

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-inv38.6

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}}}{2}\]
    6. Simplified4.7

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

    if -3.063397748446981e+71 < b < 3.1295384133612364e-73

    1. Initial program 13.0

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-inv13.2

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

    if 3.1295384133612364e-73 < b

    1. Initial program 52.3

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-inv52.3

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

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

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

Reproduce

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