Average Error: 19.6 → 8.1
Time: 7.8s
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.120083830114914597173316368847253992683 \cdot 10^{100}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{c}{\sqrt[3]{b}}\right)\right) - 2 \cdot b}\\ \end{array}\\ \mathbf{elif}\;b \le 1.391022219120490870209261122719458055916 \cdot 10^{74}:\\ \;\;\;\;\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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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 \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.120083830114914597173316368847253992683 \cdot 10^{100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

\end{array}\\

\mathbf{elif}\;b \le 1.391022219120490870209261122719458055916 \cdot 10^{74}:\\
\;\;\;\;\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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\

\end{array}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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}
double f(double a, double b, double c) {
        double r61363 = b;
        double r61364 = 0.0;
        bool r61365 = r61363 >= r61364;
        double r61366 = -r61363;
        double r61367 = r61363 * r61363;
        double r61368 = 4.0;
        double r61369 = a;
        double r61370 = r61368 * r61369;
        double r61371 = c;
        double r61372 = r61370 * r61371;
        double r61373 = r61367 - r61372;
        double r61374 = sqrt(r61373);
        double r61375 = r61366 - r61374;
        double r61376 = 2.0;
        double r61377 = r61376 * r61369;
        double r61378 = r61375 / r61377;
        double r61379 = r61376 * r61371;
        double r61380 = r61366 + r61374;
        double r61381 = r61379 / r61380;
        double r61382 = r61365 ? r61378 : r61381;
        return r61382;
}

double f(double a, double b, double c) {
        double r61383 = b;
        double r61384 = -1.1200838301149146e+100;
        bool r61385 = r61383 <= r61384;
        double r61386 = 0.0;
        bool r61387 = r61383 >= r61386;
        double r61388 = -r61383;
        double r61389 = r61383 * r61383;
        double r61390 = 4.0;
        double r61391 = a;
        double r61392 = r61390 * r61391;
        double r61393 = c;
        double r61394 = r61392 * r61393;
        double r61395 = r61389 - r61394;
        double r61396 = sqrt(r61395);
        double r61397 = sqrt(r61396);
        double r61398 = r61397 * r61397;
        double r61399 = r61388 - r61398;
        double r61400 = 2.0;
        double r61401 = r61400 * r61391;
        double r61402 = r61399 / r61401;
        double r61403 = r61400 * r61393;
        double r61404 = cbrt(r61383);
        double r61405 = r61404 * r61404;
        double r61406 = r61391 / r61405;
        double r61407 = cbrt(r61406);
        double r61408 = r61407 * r61407;
        double r61409 = r61393 / r61404;
        double r61410 = r61407 * r61409;
        double r61411 = r61408 * r61410;
        double r61412 = r61400 * r61411;
        double r61413 = 2.0;
        double r61414 = r61413 * r61383;
        double r61415 = r61412 - r61414;
        double r61416 = r61403 / r61415;
        double r61417 = r61387 ? r61402 : r61416;
        double r61418 = 1.3910222191204909e+74;
        bool r61419 = r61383 <= r61418;
        double r61420 = r61388 - r61396;
        double r61421 = r61420 / r61401;
        double r61422 = r61388 + r61398;
        double r61423 = r61403 / r61422;
        double r61424 = r61387 ? r61421 : r61423;
        double r61425 = r61391 * r61393;
        double r61426 = r61425 / r61383;
        double r61427 = r61400 * r61426;
        double r61428 = r61427 - r61414;
        double r61429 = r61428 / r61401;
        double r61430 = r61388 + r61396;
        double r61431 = r61403 / r61430;
        double r61432 = r61387 ? r61429 : r61431;
        double r61433 = r61419 ? r61424 : r61432;
        double r61434 = r61385 ? r61417 : r61433;
        return r61434;
}

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.1200838301149146e+100

    1. Initial program 30.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. 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. Using strategy rm
    4. Applied add-cube-cbrt6.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}:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}} - 2 \cdot b}\\ \end{array}\]
    5. Applied times-frac2.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 \color{blue}{c}}{2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}}\right) - 2 \cdot b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt2.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}{2 \cdot \left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \frac{c}{\sqrt[3]{b}}\right) - 2 \cdot b}\\ \end{array}\]
    8. Applied associate-*l*2.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 \color{blue}{c}}{2 \cdot \left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{c}{\sqrt[3]{b}}\right)\right) - 2 \cdot b}\\ \end{array}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt2.6

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

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

    if -1.1200838301149146e+100 < b < 1.3910222191204909e+74

    1. Initial program 8.9

      \[\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-sqr-sqrt8.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{2 \cdot c}{\color{blue}{\left(-b\right)} + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\]
    4. Applied sqrt-prod9.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}{\color{blue}{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \end{array}\]

    if 1.3910222191204909e+74 < b

    1. Initial program 41.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. Taylor expanded around inf 12.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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 simplification8.1

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

Reproduce

herbie shell --seed 2019322 
(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)))))))