Average Error: 19.8 → 8.0
Time: 6.1s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.33861703157570726 \cdot 10^{154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.77017414835012383 \cdot 10^{70}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \frac{\sqrt{{\left(b \cdot b\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{2 \cdot a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -1.33861703157570726 \cdot 10^{154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}\\

\mathbf{elif}\;b \le 1.77017414835012383 \cdot 10^{70}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\

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

\end{array}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) - 2 \cdot b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \frac{\sqrt{{\left(b \cdot b\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{2 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r36360 = b;
        double r36361 = 0.0;
        bool r36362 = r36360 >= r36361;
        double r36363 = 2.0;
        double r36364 = c;
        double r36365 = r36363 * r36364;
        double r36366 = -r36360;
        double r36367 = r36360 * r36360;
        double r36368 = 4.0;
        double r36369 = a;
        double r36370 = r36368 * r36369;
        double r36371 = r36370 * r36364;
        double r36372 = r36367 - r36371;
        double r36373 = sqrt(r36372);
        double r36374 = r36366 - r36373;
        double r36375 = r36365 / r36374;
        double r36376 = r36366 + r36373;
        double r36377 = r36363 * r36369;
        double r36378 = r36376 / r36377;
        double r36379 = r36362 ? r36375 : r36378;
        return r36379;
}

double f(double a, double b, double c) {
        double r36380 = b;
        double r36381 = -1.3386170315757073e+154;
        bool r36382 = r36380 <= r36381;
        double r36383 = 0.0;
        bool r36384 = r36380 >= r36383;
        double r36385 = 2.0;
        double r36386 = c;
        double r36387 = r36385 * r36386;
        double r36388 = -r36380;
        double r36389 = r36380 * r36380;
        double r36390 = 4.0;
        double r36391 = a;
        double r36392 = r36390 * r36391;
        double r36393 = r36392 * r36386;
        double r36394 = r36389 - r36393;
        double r36395 = sqrt(r36394);
        double r36396 = r36388 - r36395;
        double r36397 = r36387 / r36396;
        double r36398 = r36391 * r36386;
        double r36399 = r36398 / r36380;
        double r36400 = r36385 * r36399;
        double r36401 = r36400 - r36380;
        double r36402 = r36388 + r36401;
        double r36403 = r36385 * r36391;
        double r36404 = r36402 / r36403;
        double r36405 = r36384 ? r36397 : r36404;
        double r36406 = 1.7701741483501238e+70;
        bool r36407 = r36380 <= r36406;
        double r36408 = cbrt(r36394);
        double r36409 = fabs(r36408);
        double r36410 = sqrt(r36408);
        double r36411 = r36409 * r36410;
        double r36412 = r36388 - r36411;
        double r36413 = r36387 / r36412;
        double r36414 = r36388 + r36395;
        double r36415 = r36414 / r36403;
        double r36416 = r36384 ? r36413 : r36415;
        double r36417 = cbrt(r36380);
        double r36418 = r36417 * r36417;
        double r36419 = r36391 / r36418;
        double r36420 = r36386 / r36417;
        double r36421 = cbrt(r36420);
        double r36422 = r36421 * r36421;
        double r36423 = r36419 * r36422;
        double r36424 = r36423 * r36421;
        double r36425 = r36385 * r36424;
        double r36426 = 2.0;
        double r36427 = r36426 * r36380;
        double r36428 = r36425 - r36427;
        double r36429 = r36387 / r36428;
        double r36430 = 3.0;
        double r36431 = pow(r36389, r36430);
        double r36432 = pow(r36393, r36430);
        double r36433 = r36431 - r36432;
        double r36434 = sqrt(r36433);
        double r36435 = r36389 * r36389;
        double r36436 = r36393 * r36393;
        double r36437 = r36389 * r36393;
        double r36438 = r36436 + r36437;
        double r36439 = r36435 + r36438;
        double r36440 = sqrt(r36439);
        double r36441 = r36434 / r36440;
        double r36442 = r36388 + r36441;
        double r36443 = r36442 / r36403;
        double r36444 = r36384 ? r36429 : r36443;
        double r36445 = r36407 ? r36416 : r36444;
        double r36446 = r36382 ? r36405 : r36445;
        return r36446;
}

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.3386170315757073e+154

    1. Initial program 64.0

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around -inf 11.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{2 \cdot a}\\ \end{array}\]

    if -1.3386170315757073e+154 < b < 1.7701741483501238e+70

    1. Initial program 9.0

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt9.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Applied sqrt-prod9.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    5. Simplified9.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]

    if 1.7701741483501238e+70 < b

    1. Initial program 27.6

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around inf 7.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt7.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{\color{blue}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    5. Applied times-frac3.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \color{blue}{\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}}\right)} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt3.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)}\right) - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    8. Applied associate-*r*3.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \color{blue}{\left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    9. Using strategy rm
    10. Applied flip3--3.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\frac{{\left(b \cdot b\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{2 \cdot a}\\ \end{array}\]
    11. Applied sqrt-div3.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \frac{\sqrt{{\left(b \cdot b\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{2 \cdot a}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.33861703157570726 \cdot 10^{154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.77017414835012383 \cdot 10^{70}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt[3]{\frac{c}{\sqrt[3]{b}}} \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right)\right) \cdot \sqrt[3]{\frac{c}{\sqrt[3]{b}}}\right) - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \frac{\sqrt{{\left(b \cdot b\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  :precision binary64
  (if (>= b 0.0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))