Average Error: 33.2 → 10.6
Time: 29.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 -3.5748480491313226 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 3.821014310434392 \cdot 10^{-21}:\\ \;\;\;\;\frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{\frac{a \cdot 2}{\sqrt{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}\\ \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 -3.5748480491313226 \cdot 10^{+106}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1936951 = b;
        double r1936952 = -r1936951;
        double r1936953 = r1936951 * r1936951;
        double r1936954 = 4.0;
        double r1936955 = a;
        double r1936956 = r1936954 * r1936955;
        double r1936957 = c;
        double r1936958 = r1936956 * r1936957;
        double r1936959 = r1936953 - r1936958;
        double r1936960 = sqrt(r1936959);
        double r1936961 = r1936952 + r1936960;
        double r1936962 = 2.0;
        double r1936963 = r1936962 * r1936955;
        double r1936964 = r1936961 / r1936963;
        return r1936964;
}

double f(double a, double b, double c) {
        double r1936965 = b;
        double r1936966 = -3.5748480491313226e+106;
        bool r1936967 = r1936965 <= r1936966;
        double r1936968 = c;
        double r1936969 = r1936968 / r1936965;
        double r1936970 = a;
        double r1936971 = r1936965 / r1936970;
        double r1936972 = r1936969 - r1936971;
        double r1936973 = 3.821014310434392e-21;
        bool r1936974 = r1936965 <= r1936973;
        double r1936975 = -r1936965;
        double r1936976 = r1936965 * r1936965;
        double r1936977 = 4.0;
        double r1936978 = r1936977 * r1936970;
        double r1936979 = r1936968 * r1936978;
        double r1936980 = r1936976 - r1936979;
        double r1936981 = sqrt(r1936980);
        double r1936982 = r1936975 + r1936981;
        double r1936983 = sqrt(r1936982);
        double r1936984 = 2.0;
        double r1936985 = r1936970 * r1936984;
        double r1936986 = r1936985 / r1936983;
        double r1936987 = r1936983 / r1936986;
        double r1936988 = -r1936969;
        double r1936989 = r1936974 ? r1936987 : r1936988;
        double r1936990 = r1936967 ? r1936972 : r1936989;
        return r1936990;
}

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.5748480491313226e+106

    1. Initial program 46.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.5

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

    if -3.5748480491313226e+106 < b < 3.821014310434392e-21

    1. Initial program 14.8

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

      \[\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 associate-/l*15.2

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

    if 3.821014310434392e-21 < b

    1. Initial program 54.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.5748480491313226 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 3.821014310434392 \cdot 10^{-21}:\\ \;\;\;\;\frac{\sqrt{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{\frac{a \cdot 2}{\sqrt{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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