Average Error: 19.9 → 6.7
Time: 16.5s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -3.098467977454582102316048322967968795279 \cdot 10^{76}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2 + \frac{2 \cdot a}{\frac{b}{c}}}\\ \end{array}\\ \mathbf{elif}\;b \le 2.477477027570354726331144001887489320672 \cdot 10^{83}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\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}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - \left(\frac{2}{\sqrt{b}} \cdot \sqrt[3]{c}\right) \cdot \left(\frac{a}{\sqrt{b}} \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right)\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{b \cdot -2 + \frac{2 \cdot a}{\frac{b}{c}}}\\

\end{array}\\

\mathbf{elif}\;b \le 2.477477027570354726331144001887489320672 \cdot 10^{83}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\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}}}{2 \cdot a}\\

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r32512 = b;
        double r32513 = 0.0;
        bool r32514 = r32512 >= r32513;
        double r32515 = -r32512;
        double r32516 = r32512 * r32512;
        double r32517 = 4.0;
        double r32518 = a;
        double r32519 = r32517 * r32518;
        double r32520 = c;
        double r32521 = r32519 * r32520;
        double r32522 = r32516 - r32521;
        double r32523 = sqrt(r32522);
        double r32524 = r32515 - r32523;
        double r32525 = 2.0;
        double r32526 = r32525 * r32518;
        double r32527 = r32524 / r32526;
        double r32528 = r32525 * r32520;
        double r32529 = r32515 + r32523;
        double r32530 = r32528 / r32529;
        double r32531 = r32514 ? r32527 : r32530;
        return r32531;
}

double f(double a, double b, double c) {
        double r32532 = b;
        double r32533 = -3.098467977454582e+76;
        bool r32534 = r32532 <= r32533;
        double r32535 = 0.0;
        bool r32536 = r32532 >= r32535;
        double r32537 = -r32532;
        double r32538 = r32532 * r32532;
        double r32539 = 4.0;
        double r32540 = a;
        double r32541 = r32539 * r32540;
        double r32542 = c;
        double r32543 = r32541 * r32542;
        double r32544 = r32538 - r32543;
        double r32545 = sqrt(r32544);
        double r32546 = r32537 - r32545;
        double r32547 = 2.0;
        double r32548 = r32547 * r32540;
        double r32549 = r32546 / r32548;
        double r32550 = r32542 * r32547;
        double r32551 = -2.0;
        double r32552 = r32532 * r32551;
        double r32553 = r32532 / r32542;
        double r32554 = r32548 / r32553;
        double r32555 = r32552 + r32554;
        double r32556 = r32550 / r32555;
        double r32557 = r32536 ? r32549 : r32556;
        double r32558 = 2.4774770275703547e+83;
        bool r32559 = r32532 <= r32558;
        double r32560 = cbrt(r32544);
        double r32561 = fabs(r32560);
        double r32562 = sqrt(r32560);
        double r32563 = r32561 * r32562;
        double r32564 = r32537 - r32563;
        double r32565 = r32564 / r32548;
        double r32566 = r32545 + r32537;
        double r32567 = r32550 / r32566;
        double r32568 = r32536 ? r32565 : r32567;
        double r32569 = sqrt(r32532);
        double r32570 = r32547 / r32569;
        double r32571 = cbrt(r32542);
        double r32572 = r32570 * r32571;
        double r32573 = r32540 / r32569;
        double r32574 = r32571 * r32571;
        double r32575 = r32573 * r32574;
        double r32576 = r32572 * r32575;
        double r32577 = r32532 - r32576;
        double r32578 = r32537 - r32577;
        double r32579 = r32578 / r32548;
        double r32580 = r32536 ? r32579 : r32567;
        double r32581 = r32559 ? r32568 : r32580;
        double r32582 = r32534 ? r32557 : r32581;
        return r32582;
}

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 < -3.098467977454582e+76

    1. Initial program 27.3

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

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

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

    if -3.098467977454582e+76 < b < 2.4774770275703547e+83

    1. Initial program 9.1

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\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}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    4. Applied sqrt-prod9.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\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}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    5. Simplified9.3

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

    if 2.4774770275703547e+83 < b

    1. Initial program 43.8

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.098467977454582102316048322967968795279 \cdot 10^{76}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{b \cdot -2 + \frac{2 \cdot a}{\frac{b}{c}}}\\ \end{array}\\ \mathbf{elif}\;b \le 2.477477027570354726331144001887489320672 \cdot 10^{83}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\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}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - \left(\frac{2}{\sqrt{b}} \cdot \sqrt[3]{c}\right) \cdot \left(\frac{a}{\sqrt{b}} \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right)\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))