Average Error: 33.6 → 10.4
Time: 20.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 -2.1144981103869975 \cdot 10^{+131}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 4.5810084990875205 \cdot 10^{-68}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b + c \cdot \left(-4 \cdot a\right)} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;-\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.1144981103869975 \cdot 10^{+131}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r2348102 = b;
        double r2348103 = -r2348102;
        double r2348104 = r2348102 * r2348102;
        double r2348105 = 4.0;
        double r2348106 = a;
        double r2348107 = r2348105 * r2348106;
        double r2348108 = c;
        double r2348109 = r2348107 * r2348108;
        double r2348110 = r2348104 - r2348109;
        double r2348111 = sqrt(r2348110);
        double r2348112 = r2348103 + r2348111;
        double r2348113 = 2.0;
        double r2348114 = r2348113 * r2348106;
        double r2348115 = r2348112 / r2348114;
        return r2348115;
}

double f(double a, double b, double c) {
        double r2348116 = b;
        double r2348117 = -2.1144981103869975e+131;
        bool r2348118 = r2348116 <= r2348117;
        double r2348119 = c;
        double r2348120 = r2348119 / r2348116;
        double r2348121 = a;
        double r2348122 = r2348116 / r2348121;
        double r2348123 = r2348120 - r2348122;
        double r2348124 = 4.5810084990875205e-68;
        bool r2348125 = r2348116 <= r2348124;
        double r2348126 = 1.0;
        double r2348127 = r2348116 * r2348116;
        double r2348128 = -4.0;
        double r2348129 = r2348128 * r2348121;
        double r2348130 = r2348119 * r2348129;
        double r2348131 = r2348127 + r2348130;
        double r2348132 = sqrt(r2348131);
        double r2348133 = r2348132 - r2348116;
        double r2348134 = 2.0;
        double r2348135 = r2348133 / r2348134;
        double r2348136 = r2348121 / r2348135;
        double r2348137 = r2348126 / r2348136;
        double r2348138 = -r2348120;
        double r2348139 = r2348125 ? r2348137 : r2348138;
        double r2348140 = r2348118 ? r2348123 : r2348139;
        return r2348140;
}

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 < -2.1144981103869975e+131

    1. Initial program 53.8

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -2.1144981103869975e+131 < b < 4.5810084990875205e-68

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c} - b}{2}}}{a}\]
    8. Using strategy rm
    9. Applied clear-num13.4

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

    if 4.5810084990875205e-68 < b

    1. Initial program 52.0

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

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

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

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

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

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

Reproduce

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