Average Error: 34.2 → 10.0
Time: 17.1s
Precision: 64
\[b \cdot b - \left(4 \cdot a\right) \cdot c \ge 0.0\]
\[\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.940001550635406357572527191036557327772 \cdot 10^{93}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 2.592868408155405548302080990651854167189 \cdot 10^{-64}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \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.940001550635406357572527191036557327772 \cdot 10^{93}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\

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

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

\end{array}
double f(double b, double a, double c) {
        double r23805906 = b;
        double r23805907 = -r23805906;
        double r23805908 = r23805906 * r23805906;
        double r23805909 = 4.0;
        double r23805910 = a;
        double r23805911 = r23805909 * r23805910;
        double r23805912 = c;
        double r23805913 = r23805911 * r23805912;
        double r23805914 = r23805908 - r23805913;
        double r23805915 = sqrt(r23805914);
        double r23805916 = r23805907 + r23805915;
        double r23805917 = 2.0;
        double r23805918 = r23805917 * r23805910;
        double r23805919 = r23805916 / r23805918;
        return r23805919;
}

double f(double b, double a, double c) {
        double r23805920 = b;
        double r23805921 = -2.9400015506354064e+93;
        bool r23805922 = r23805920 <= r23805921;
        double r23805923 = c;
        double r23805924 = r23805923 / r23805920;
        double r23805925 = a;
        double r23805926 = r23805920 / r23805925;
        double r23805927 = r23805924 - r23805926;
        double r23805928 = 1.0;
        double r23805929 = r23805927 * r23805928;
        double r23805930 = 2.5928684081554055e-64;
        bool r23805931 = r23805920 <= r23805930;
        double r23805932 = r23805920 * r23805920;
        double r23805933 = 4.0;
        double r23805934 = r23805925 * r23805933;
        double r23805935 = r23805934 * r23805923;
        double r23805936 = r23805932 - r23805935;
        double r23805937 = sqrt(r23805936);
        double r23805938 = r23805937 - r23805920;
        double r23805939 = 1.0;
        double r23805940 = 2.0;
        double r23805941 = r23805925 * r23805940;
        double r23805942 = r23805939 / r23805941;
        double r23805943 = r23805938 * r23805942;
        double r23805944 = -1.0;
        double r23805945 = r23805924 * r23805944;
        double r23805946 = r23805931 ? r23805943 : r23805945;
        double r23805947 = r23805922 ? r23805929 : r23805946;
        return r23805947;
}

Error

Bits error versus b

Bits error versus a

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.9400015506354064e+93

    1. Initial program 45.8

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

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

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

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

    if -2.9400015506354064e+93 < b < 2.5928684081554055e-64

    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{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}}\]
    3. Using strategy rm
    4. Applied clear-num13.1

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

      \[\leadsto \frac{1}{\color{blue}{\left(a \cdot 2\right) \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}\]
    7. Applied *-un-lft-identity13.2

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

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

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

    if 2.5928684081554055e-64 < b

    1. Initial program 53.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 2.592868408155405548302080990651854167189 \cdot 10^{-64}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "((-b)+sqrt(b*b-4*a*c))/(2*a)"
  :pre (>= (- (* b b) (* (* 4.0 a) c)) 0.0)
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))