Average Error: 34.2 → 8.7
Time: 17.5s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 7.863575863781199763111272908142285289458 \cdot 10^{-222}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.697192458191632034009038064514048334805 \cdot 10^{79}:\\ \;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double b, double a, double c) {
        double r574780 = b;
        double r574781 = -r574780;
        double r574782 = 2.0;
        double r574783 = pow(r574780, r574782);
        double r574784 = 4.0;
        double r574785 = a;
        double r574786 = r574784 * r574785;
        double r574787 = c;
        double r574788 = r574786 * r574787;
        double r574789 = r574783 - r574788;
        double r574790 = sqrt(r574789);
        double r574791 = r574781 + r574790;
        double r574792 = r574782 * r574785;
        double r574793 = r574791 / r574792;
        return r574793;
}

double f(double b, double a, double c) {
        double r574794 = b;
        double r574795 = -2.9400015506354064e+93;
        bool r574796 = r574794 <= r574795;
        double r574797 = 1.0;
        double r574798 = c;
        double r574799 = r574798 / r574794;
        double r574800 = a;
        double r574801 = r574794 / r574800;
        double r574802 = r574799 - r574801;
        double r574803 = r574797 * r574802;
        double r574804 = 7.8635758637812e-222;
        bool r574805 = r574794 <= r574804;
        double r574806 = -r574794;
        double r574807 = 2.0;
        double r574808 = pow(r574794, r574807);
        double r574809 = 4.0;
        double r574810 = r574800 * r574798;
        double r574811 = r574809 * r574810;
        double r574812 = r574808 - r574811;
        double r574813 = sqrt(r574812);
        double r574814 = r574806 + r574813;
        double r574815 = 2.0;
        double r574816 = r574815 * r574800;
        double r574817 = r574814 / r574816;
        double r574818 = 1.697192458191632e+79;
        bool r574819 = r574794 <= r574818;
        double r574820 = r574809 * r574800;
        double r574821 = r574820 * r574798;
        double r574822 = r574806 - r574813;
        double r574823 = r574821 / r574822;
        double r574824 = r574823 / r574816;
        double r574825 = -1.0;
        double r574826 = r574825 * r574799;
        double r574827 = r574819 ? r574824 : r574826;
        double r574828 = r574805 ? r574817 : r574827;
        double r574829 = r574796 ? r574803 : r574828;
        return r574829;
}

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 4 regimes
  2. if b < -2.9400015506354064e+93

    1. Initial program 45.8

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

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

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

    if -2.9400015506354064e+93 < b < 7.8635758637812e-222

    1. Initial program 9.8

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

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

    if 7.8635758637812e-222 < b < 1.697192458191632e+79

    1. Initial program 34.6

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

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

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

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

    if 1.697192458191632e+79 < b

    1. Initial program 58.3

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

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

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

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "(-b+sqrt(b^2-4*a*c))/(2*a)"
  :precision binary64
  (/ (+ (- b) (sqrt (- (pow b 2) (* (* 4 a) c)))) (* 2 a)))