Average Error: 33.8 → 15.6
Time: 18.6s
Precision: 64
\[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.353963815049489770257451259752669467013 \cdot 10^{154}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)\right)\\ \mathbf{elif}\;b \le 1.63906928244180265923045087921028351019 \cdot 10^{-8}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \left(4 \cdot a\right)\right) \cdot \sqrt[3]{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(-2 \cdot \frac{a \cdot c}{b}\right)\\ \end{array}\]
\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)
\begin{array}{l}
\mathbf{if}\;b \le -1.353963815049489770257451259752669467013 \cdot 10^{154}:\\
\;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)\right)\\

\mathbf{elif}\;b \le 1.63906928244180265923045087921028351019 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \left(4 \cdot a\right)\right) \cdot \sqrt[3]{c}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot a} \cdot \left(-2 \cdot \frac{a \cdot c}{b}\right)\\

\end{array}
double f(double a, double b, double c) {
        double r597075 = 1.0;
        double r597076 = 2.0;
        double r597077 = a;
        double r597078 = r597076 * r597077;
        double r597079 = r597075 / r597078;
        double r597080 = b;
        double r597081 = -r597080;
        double r597082 = pow(r597080, r597076);
        double r597083 = 4.0;
        double r597084 = r597083 * r597077;
        double r597085 = c;
        double r597086 = r597084 * r597085;
        double r597087 = r597082 - r597086;
        double r597088 = sqrt(r597087);
        double r597089 = r597081 + r597088;
        double r597090 = r597079 * r597089;
        return r597090;
}

double f(double a, double b, double c) {
        double r597091 = b;
        double r597092 = -1.3539638150494898e+154;
        bool r597093 = r597091 <= r597092;
        double r597094 = 1.0;
        double r597095 = 2.0;
        double r597096 = a;
        double r597097 = r597095 * r597096;
        double r597098 = r597094 / r597097;
        double r597099 = -r597091;
        double r597100 = c;
        double r597101 = r597096 * r597100;
        double r597102 = r597101 / r597091;
        double r597103 = r597095 * r597102;
        double r597104 = r597103 - r597091;
        double r597105 = r597099 + r597104;
        double r597106 = r597098 * r597105;
        double r597107 = 1.6390692824418027e-08;
        bool r597108 = r597091 <= r597107;
        double r597109 = pow(r597091, r597095);
        double r597110 = cbrt(r597100);
        double r597111 = r597110 * r597110;
        double r597112 = 4.0;
        double r597113 = r597112 * r597096;
        double r597114 = r597111 * r597113;
        double r597115 = r597114 * r597110;
        double r597116 = r597109 - r597115;
        double r597117 = sqrt(r597116);
        double r597118 = r597099 + r597117;
        double r597119 = r597098 * r597118;
        double r597120 = -2.0;
        double r597121 = r597120 * r597102;
        double r597122 = r597098 * r597121;
        double r597123 = r597108 ? r597119 : r597122;
        double r597124 = r597093 ? r597106 : r597123;
        return r597124;
}

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 < -1.3539638150494898e+154

    1. Initial program 64.0

      \[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt64.0

      \[\leadsto \frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}\right)}}\right)\]
    4. Applied associate-*r*64.0

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

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

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

    if -1.3539638150494898e+154 < b < 1.6390692824418027e-08

    1. Initial program 14.7

      \[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt15.0

      \[\leadsto \frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}\right)}}\right)\]
    4. Applied associate-*r*15.0

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

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

    if 1.6390692824418027e-08 < b

    1. Initial program 54.8

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

      \[\leadsto \frac{1}{2 \cdot a} \cdot \color{blue}{\left(-2 \cdot \frac{a \cdot c}{b}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.353963815049489770257451259752669467013 \cdot 10^{154}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)\right)\\ \mathbf{elif}\;b \le 1.63906928244180265923045087921028351019 \cdot 10^{-8}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \left(4 \cdot a\right)\right) \cdot \sqrt[3]{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2 \cdot a} \cdot \left(-2 \cdot \frac{a \cdot c}{b}\right)\\ \end{array}\]

Reproduce

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