Average Error: 33.8 → 10.7
Time: 58.4s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.554334380656473166047169134650490279571 \cdot 10^{60}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le -3.43629125879031642394551270881625565751 \cdot 10^{-161}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a} \cdot \frac{\left(c \cdot a\right) \cdot 4}{2 \cdot \left(\left(b \cdot b - b \cdot b\right) + \left(c \cdot a\right) \cdot 4\right)}\\ \mathbf{elif}\;b \le 1.958082194924451042912296607079150108999 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{4 \cdot a}{2} \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -1}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.554334380656473166047169134650490279571 \cdot 10^{60}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\

\mathbf{elif}\;b \le -3.43629125879031642394551270881625565751 \cdot 10^{-161}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a} \cdot \frac{\left(c \cdot a\right) \cdot 4}{2 \cdot \left(\left(b \cdot b - b \cdot b\right) + \left(c \cdot a\right) \cdot 4\right)}\\

\mathbf{elif}\;b \le 1.958082194924451042912296607079150108999 \cdot 10^{133}:\\
\;\;\;\;\frac{\frac{4 \cdot a}{2} \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -1}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r146501 = b;
        double r146502 = -r146501;
        double r146503 = r146501 * r146501;
        double r146504 = 4.0;
        double r146505 = a;
        double r146506 = r146504 * r146505;
        double r146507 = c;
        double r146508 = r146506 * r146507;
        double r146509 = r146503 - r146508;
        double r146510 = sqrt(r146509);
        double r146511 = r146502 + r146510;
        double r146512 = 2.0;
        double r146513 = r146512 * r146505;
        double r146514 = r146511 / r146513;
        return r146514;
}

double f(double a, double b, double c) {
        double r146515 = b;
        double r146516 = -1.5543343806564732e+60;
        bool r146517 = r146515 <= r146516;
        double r146518 = c;
        double r146519 = r146518 / r146515;
        double r146520 = a;
        double r146521 = r146515 / r146520;
        double r146522 = r146519 - r146521;
        double r146523 = 1.0;
        double r146524 = r146522 * r146523;
        double r146525 = -3.4362912587903164e-161;
        bool r146526 = r146515 <= r146525;
        double r146527 = r146515 * r146515;
        double r146528 = r146518 * r146520;
        double r146529 = 4.0;
        double r146530 = r146528 * r146529;
        double r146531 = r146527 - r146530;
        double r146532 = sqrt(r146531);
        double r146533 = r146532 - r146515;
        double r146534 = r146533 / r146520;
        double r146535 = 2.0;
        double r146536 = r146527 - r146527;
        double r146537 = r146536 + r146530;
        double r146538 = r146535 * r146537;
        double r146539 = r146530 / r146538;
        double r146540 = r146534 * r146539;
        double r146541 = 1.958082194924451e+133;
        bool r146542 = r146515 <= r146541;
        double r146543 = r146529 * r146520;
        double r146544 = r146543 / r146535;
        double r146545 = -r146515;
        double r146546 = r146545 - r146532;
        double r146547 = r146518 / r146546;
        double r146548 = r146544 * r146547;
        double r146549 = r146548 / r146520;
        double r146550 = -1.0;
        double r146551 = r146518 * r146550;
        double r146552 = r146551 / r146515;
        double r146553 = r146542 ? r146549 : r146552;
        double r146554 = r146526 ? r146540 : r146553;
        double r146555 = r146517 ? r146524 : r146554;
        return r146555;
}

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 4 regimes
  2. if b < -1.5543343806564732e+60

    1. Initial program 39.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around -inf 4.8

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified4.8

      \[\leadsto \color{blue}{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1}\]

    if -1.5543343806564732e+60 < b < -3.4362912587903164e-161

    1. Initial program 6.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+39.1

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    4. Simplified39.2

      \[\leadsto \frac{\frac{\color{blue}{0 + \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied flip--39.2

      \[\leadsto \frac{\frac{0 + \left(4 \cdot a\right) \cdot c}{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}{2 \cdot a}\]
    7. Applied associate-/r/39.2

      \[\leadsto \frac{\color{blue}{\frac{0 + \left(4 \cdot a\right) \cdot c}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    8. Applied times-frac39.2

      \[\leadsto \color{blue}{\frac{\frac{0 + \left(4 \cdot a\right) \cdot c}{\left(-b\right) \cdot \left(-b\right) - \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 \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}}\]
    9. Simplified17.2

      \[\leadsto \color{blue}{\frac{4 \cdot \left(a \cdot c\right)}{\left(\left(b \cdot b - b \cdot b\right) + 4 \cdot \left(a \cdot c\right)\right) \cdot 2}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a}\]
    10. Simplified17.2

      \[\leadsto \frac{4 \cdot \left(a \cdot c\right)}{\left(\left(b \cdot b - b \cdot b\right) + 4 \cdot \left(a \cdot c\right)\right) \cdot 2} \cdot \color{blue}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a}}\]

    if -3.4362912587903164e-161 < b < 1.958082194924451e+133

    1. Initial program 29.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+29.9

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    4. Simplified16.6

      \[\leadsto \frac{\frac{\color{blue}{0 + \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied associate-/r*16.7

      \[\leadsto \color{blue}{\frac{\frac{\frac{0 + \left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2}}{a}}\]
    7. Simplified14.8

      \[\leadsto \frac{\color{blue}{\frac{4 \cdot a}{2} \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{a}\]

    if 1.958082194924451e+133 < b

    1. Initial program 61.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 1.7

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified1.7

      \[\leadsto \color{blue}{\frac{c \cdot -1}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.554334380656473166047169134650490279571 \cdot 10^{60}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le -3.43629125879031642394551270881625565751 \cdot 10^{-161}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a} \cdot \frac{\left(c \cdot a\right) \cdot 4}{2 \cdot \left(\left(b \cdot b - b \cdot b\right) + \left(c \cdot a\right) \cdot 4\right)}\\ \mathbf{elif}\;b \le 1.958082194924451042912296607079150108999 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{4 \cdot a}{2} \cdot \frac{c}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -1}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019195 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))