Average Error: 33.8 → 9.1
Time: 8.0s
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.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -1.1919475510853474 \cdot 10^{-247}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.98249778396328792 \cdot 10^{-19}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{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 -3.12428337420519208 \cdot 10^{57}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r43942 = b;
        double r43943 = -r43942;
        double r43944 = r43942 * r43942;
        double r43945 = 4.0;
        double r43946 = a;
        double r43947 = r43945 * r43946;
        double r43948 = c;
        double r43949 = r43947 * r43948;
        double r43950 = r43944 - r43949;
        double r43951 = sqrt(r43950);
        double r43952 = r43943 + r43951;
        double r43953 = 2.0;
        double r43954 = r43953 * r43946;
        double r43955 = r43952 / r43954;
        return r43955;
}

double f(double a, double b, double c) {
        double r43956 = b;
        double r43957 = -3.124283374205192e+57;
        bool r43958 = r43956 <= r43957;
        double r43959 = 1.0;
        double r43960 = c;
        double r43961 = r43960 / r43956;
        double r43962 = a;
        double r43963 = r43956 / r43962;
        double r43964 = r43961 - r43963;
        double r43965 = r43959 * r43964;
        double r43966 = -1.1919475510853474e-247;
        bool r43967 = r43956 <= r43966;
        double r43968 = -r43956;
        double r43969 = r43956 * r43956;
        double r43970 = 4.0;
        double r43971 = r43970 * r43962;
        double r43972 = r43971 * r43960;
        double r43973 = r43969 - r43972;
        double r43974 = sqrt(r43973);
        double r43975 = r43968 + r43974;
        double r43976 = 1.0;
        double r43977 = 2.0;
        double r43978 = r43977 * r43962;
        double r43979 = r43976 / r43978;
        double r43980 = r43975 * r43979;
        double r43981 = 3.982497783963288e-19;
        bool r43982 = r43956 <= r43981;
        double r43983 = r43962 * r43960;
        double r43984 = r43970 * r43983;
        double r43985 = r43956 - r43956;
        double r43986 = r43956 * r43985;
        double r43987 = r43984 + r43986;
        double r43988 = r43968 - r43974;
        double r43989 = r43987 / r43988;
        double r43990 = r43989 / r43978;
        double r43991 = -1.0;
        double r43992 = r43991 * r43961;
        double r43993 = r43982 ? r43990 : r43992;
        double r43994 = r43967 ? r43980 : r43993;
        double r43995 = r43958 ? r43965 : r43994;
        return r43995;
}

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 < -3.124283374205192e+57

    1. Initial program 39.5

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

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

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

    if -3.124283374205192e+57 < b < -1.1919475510853474e-247

    1. Initial program 8.1

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

      \[\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}}\]

    if -1.1919475510853474e-247 < b < 3.982497783963288e-19

    1. Initial program 22.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-+22.4

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

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

    if 3.982497783963288e-19 < b

    1. Initial program 55.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -1.1919475510853474 \cdot 10^{-247}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.98249778396328792 \cdot 10^{-19}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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