Average Error: 20.1 → 7.8
Time: 17.6s
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.434128173054205306503791529718852543763 \cdot 10^{153}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \frac{\sqrt{{b}^{6} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(4 \cdot \left(a \cdot c\right)\right) \cdot \left(b \cdot b + \left(4 \cdot a\right) \cdot c\right) + {b}^{4}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(2 \cdot \left(a \cdot \frac{c}{b}\right) - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le -5.066042609614386619694957941213132915138 \cdot 10^{-310} \lor \neg \left(b \le 5.031608061939102936286074782173578716838 \cdot 10^{53}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;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}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\\ \mathbf{elif}\;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}{\frac{\left(a \cdot c\right) \cdot 4}{\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.434128173054205306503791529718852543763 \cdot 10^{153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \frac{\sqrt{{b}^{6} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(4 \cdot \left(a \cdot c\right)\right) \cdot \left(b \cdot b + \left(4 \cdot a\right) \cdot c\right) + {b}^{4}}}}{2 \cdot a}\\

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

\end{array}\\

\mathbf{elif}\;b \le -5.066042609614386619694957941213132915138 \cdot 10^{-310} \lor \neg \left(b \le 5.031608061939102936286074782173578716838 \cdot 10^{53}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;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}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\end{array}\\

\mathbf{elif}\;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}{\frac{\left(a \cdot c\right) \cdot 4}{\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 r34347 = b;
        double r34348 = 0.0;
        bool r34349 = r34347 >= r34348;
        double r34350 = -r34347;
        double r34351 = r34347 * r34347;
        double r34352 = 4.0;
        double r34353 = a;
        double r34354 = r34352 * r34353;
        double r34355 = c;
        double r34356 = r34354 * r34355;
        double r34357 = r34351 - r34356;
        double r34358 = sqrt(r34357);
        double r34359 = r34350 - r34358;
        double r34360 = 2.0;
        double r34361 = r34360 * r34353;
        double r34362 = r34359 / r34361;
        double r34363 = r34360 * r34355;
        double r34364 = r34350 + r34358;
        double r34365 = r34363 / r34364;
        double r34366 = r34349 ? r34362 : r34365;
        return r34366;
}

double f(double a, double b, double c) {
        double r34367 = b;
        double r34368 = -1.4341281730542053e+153;
        bool r34369 = r34367 <= r34368;
        double r34370 = 0.0;
        bool r34371 = r34367 >= r34370;
        double r34372 = -r34367;
        double r34373 = 6.0;
        double r34374 = pow(r34367, r34373);
        double r34375 = 4.0;
        double r34376 = a;
        double r34377 = r34375 * r34376;
        double r34378 = c;
        double r34379 = r34377 * r34378;
        double r34380 = 3.0;
        double r34381 = pow(r34379, r34380);
        double r34382 = r34374 - r34381;
        double r34383 = sqrt(r34382);
        double r34384 = r34376 * r34378;
        double r34385 = r34375 * r34384;
        double r34386 = r34367 * r34367;
        double r34387 = r34386 + r34379;
        double r34388 = r34385 * r34387;
        double r34389 = 4.0;
        double r34390 = pow(r34367, r34389);
        double r34391 = r34388 + r34390;
        double r34392 = sqrt(r34391);
        double r34393 = r34383 / r34392;
        double r34394 = r34372 - r34393;
        double r34395 = 2.0;
        double r34396 = r34395 * r34376;
        double r34397 = r34394 / r34396;
        double r34398 = r34395 * r34378;
        double r34399 = r34378 / r34367;
        double r34400 = r34376 * r34399;
        double r34401 = r34395 * r34400;
        double r34402 = r34401 - r34367;
        double r34403 = r34372 + r34402;
        double r34404 = r34398 / r34403;
        double r34405 = r34371 ? r34397 : r34404;
        double r34406 = -5.0660426096144e-310;
        bool r34407 = r34367 <= r34406;
        double r34408 = 5.031608061939103e+53;
        bool r34409 = r34367 <= r34408;
        double r34410 = !r34409;
        bool r34411 = r34407 || r34410;
        double r34412 = r34384 / r34367;
        double r34413 = r34395 * r34412;
        double r34414 = r34367 - r34413;
        double r34415 = r34372 - r34414;
        double r34416 = r34415 / r34396;
        double r34417 = r34386 - r34379;
        double r34418 = sqrt(r34417);
        double r34419 = r34372 + r34418;
        double r34420 = r34398 / r34419;
        double r34421 = r34371 ? r34416 : r34420;
        double r34422 = r34372 - r34418;
        double r34423 = r34422 / r34396;
        double r34424 = r34384 * r34375;
        double r34425 = r34424 / r34422;
        double r34426 = r34398 / r34425;
        double r34427 = r34371 ? r34423 : r34426;
        double r34428 = r34411 ? r34421 : r34427;
        double r34429 = r34369 ? r34405 : r34428;
        return r34429;
}

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.4341281730542053e+153

    1. Initial program 39.5

      \[\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.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}{\color{blue}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}}\\ \end{array}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity6.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(-b\right) + \left(2 \cdot \frac{a \cdot c}{1 \cdot b} - b\right)}\\ \end{array}\]
    5. Applied times-frac1.4

      \[\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(-b\right) + \left(2 \cdot \left(\frac{a}{1} \cdot \frac{c}{b}\right) - b\right)}\\ \end{array}\]
    6. Simplified1.4

      \[\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(-b\right) + \left(2 \cdot \left(a \cdot \frac{c}{b}\right) - b\right)}\\ \end{array}\]
    7. Using strategy rm
    8. Applied flip3--1.4

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

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

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

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

    if -1.4341281730542053e+153 < b < -5.0660426096144e-310 or 5.031608061939103e+53 < b

    1. Initial program 18.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 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}\]

    if -5.0660426096144e-310 < b < 5.031608061939103e+53

    1. Initial program 10.0

      \[\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-sqrt10.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{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\]
    4. Applied sqrt-prod10.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}\]
    5. Using strategy rm
    6. Applied flip-+10.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}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{\frac{\left(-b\right) \cdot \left(-b\right) - \left(\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}}\right) \cdot \left(\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}}\right)}{\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}\]
    7. Simplified10.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{\color{blue}{2 \cdot c}}{\frac{\left(a \cdot c\right) \cdot 4}{\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}\]
    8. Simplified10.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}{\frac{\left(a \cdot c\right) \cdot 4}{\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 simplification7.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.434128173054205306503791529718852543763 \cdot 10^{153}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \frac{\sqrt{{b}^{6} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{\left(4 \cdot \left(a \cdot c\right)\right) \cdot \left(b \cdot b + \left(4 \cdot a\right) \cdot c\right) + {b}^{4}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(2 \cdot \left(a \cdot \frac{c}{b}\right) - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le -5.066042609614386619694957941213132915138 \cdot 10^{-310} \lor \neg \left(b \le 5.031608061939102936286074782173578716838 \cdot 10^{53}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;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}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\\ \mathbf{elif}\;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}{\frac{\left(a \cdot c\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\]

Reproduce

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