Average Error: 19.8 → 9.0
Time: 22.0s
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 -1.396583466388814133251953653376858979069 \cdot 10^{134}:\\ \;\;\;\;\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(2 \cdot \left(\left(\frac{\left|\frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right| \cdot a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \le 2098867031.934578418731689453125:\\ \;\;\;\;\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}{\sqrt{\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}} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \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 -1.396583466388814133251953653376858979069 \cdot 10^{134}:\\
\;\;\;\;\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(2 \cdot \left(\left(\frac{\left|\frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right| \cdot a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\

\end{array}\\

\mathbf{elif}\;b \le 2098867031.934578418731689453125:\\
\;\;\;\;\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}{\sqrt{\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}} - b}\\

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r38517 = b;
        double r38518 = 0.0;
        bool r38519 = r38517 >= r38518;
        double r38520 = -r38517;
        double r38521 = r38517 * r38517;
        double r38522 = 4.0;
        double r38523 = a;
        double r38524 = r38522 * r38523;
        double r38525 = c;
        double r38526 = r38524 * r38525;
        double r38527 = r38521 - r38526;
        double r38528 = sqrt(r38527);
        double r38529 = r38520 - r38528;
        double r38530 = 2.0;
        double r38531 = r38530 * r38523;
        double r38532 = r38529 / r38531;
        double r38533 = r38530 * r38525;
        double r38534 = r38520 + r38528;
        double r38535 = r38533 / r38534;
        double r38536 = r38519 ? r38532 : r38535;
        return r38536;
}

double f(double a, double b, double c) {
        double r38537 = b;
        double r38538 = -1.3965834663888141e+134;
        bool r38539 = r38537 <= r38538;
        double r38540 = 0.0;
        bool r38541 = r38537 >= r38540;
        double r38542 = -r38537;
        double r38543 = r38537 * r38537;
        double r38544 = 4.0;
        double r38545 = a;
        double r38546 = r38544 * r38545;
        double r38547 = c;
        double r38548 = r38546 * r38547;
        double r38549 = r38543 - r38548;
        double r38550 = sqrt(r38549);
        double r38551 = r38542 - r38550;
        double r38552 = 2.0;
        double r38553 = r38552 * r38545;
        double r38554 = r38551 / r38553;
        double r38555 = r38552 * r38547;
        double r38556 = cbrt(r38547);
        double r38557 = cbrt(r38537);
        double r38558 = cbrt(r38557);
        double r38559 = r38556 / r38558;
        double r38560 = fabs(r38559);
        double r38561 = r38560 * r38545;
        double r38562 = r38557 * r38557;
        double r38563 = r38561 / r38562;
        double r38564 = r38556 * r38556;
        double r38565 = r38558 * r38558;
        double r38566 = r38564 / r38565;
        double r38567 = sqrt(r38566);
        double r38568 = r38563 * r38567;
        double r38569 = r38568 * r38559;
        double r38570 = r38552 * r38569;
        double r38571 = r38570 - r38537;
        double r38572 = r38571 - r38537;
        double r38573 = r38555 / r38572;
        double r38574 = r38541 ? r38554 : r38573;
        double r38575 = 2098867031.9345784;
        bool r38576 = r38537 <= r38575;
        double r38577 = cbrt(r38549);
        double r38578 = r38577 * r38577;
        double r38579 = r38578 * r38577;
        double r38580 = sqrt(r38579);
        double r38581 = r38580 - r38537;
        double r38582 = r38555 / r38581;
        double r38583 = r38541 ? r38554 : r38582;
        double r38584 = r38545 * r38547;
        double r38585 = r38584 / r38537;
        double r38586 = r38552 * r38585;
        double r38587 = r38537 - r38586;
        double r38588 = r38542 - r38587;
        double r38589 = r38588 / r38553;
        double r38590 = r38550 - r38537;
        double r38591 = r38555 / r38590;
        double r38592 = r38541 ? r38589 : r38591;
        double r38593 = r38576 ? r38583 : r38592;
        double r38594 = r38539 ? r38574 : r38593;
        return r38594;
}

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.3965834663888141e+134

    1. Initial program 34.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. Simplified34.1

      \[\leadsto \color{blue}{\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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around -inf 6.2

      \[\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}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}\\ \end{array}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt6.2

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \frac{a \cdot c}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}} - b\right) - b}\\ \end{array}\]
    6. Applied times-frac1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}}\right) - b\right) - b}\\ \end{array}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    9. Applied add-cube-cbrt1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    10. Applied times-frac1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right)\right) - b\right) - b}\\ \end{array}\]
    11. Applied associate-*r*1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    12. Using strategy rm
    13. Applied add-sqr-sqrt1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}} \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right)\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    14. Applied associate-*r*1.6

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right) \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    15. Simplified2.0

      \[\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}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\frac{\left|\frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right| \cdot a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \sqrt{\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]

    if -1.3965834663888141e+134 < b < 2098867031.9345784

    1. Initial program 9.7

      \[\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. Simplified9.7

      \[\leadsto \color{blue}{\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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.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}:\\ \;\;\;\;\frac{\color{blue}{2} \cdot c}{\sqrt{\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}} - b}\\ \end{array}\]

    if 2098867031.9345784 < b

    1. Initial program 32.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. Simplified32.3

      \[\leadsto \color{blue}{\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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 12.2

      \[\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}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

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

Reproduce

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