Average Error: 33.4 → 9.9
Time: 19.2s
Precision: 64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -8.856808865537945 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 8.670930634061063 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -8.856808865537945 \cdot 10^{+146}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 8.670930634061063 \cdot 10^{-143}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r550409 = b_2;
        double r550410 = -r550409;
        double r550411 = r550409 * r550409;
        double r550412 = a;
        double r550413 = c;
        double r550414 = r550412 * r550413;
        double r550415 = r550411 - r550414;
        double r550416 = sqrt(r550415);
        double r550417 = r550410 + r550416;
        double r550418 = r550417 / r550412;
        return r550418;
}

double f(double a, double b_2, double c) {
        double r550419 = b_2;
        double r550420 = -8.856808865537945e+146;
        bool r550421 = r550419 <= r550420;
        double r550422 = 0.5;
        double r550423 = c;
        double r550424 = r550423 / r550419;
        double r550425 = r550422 * r550424;
        double r550426 = a;
        double r550427 = r550419 / r550426;
        double r550428 = 2.0;
        double r550429 = r550427 * r550428;
        double r550430 = r550425 - r550429;
        double r550431 = 8.670930634061063e-143;
        bool r550432 = r550419 <= r550431;
        double r550433 = r550419 * r550419;
        double r550434 = r550423 * r550426;
        double r550435 = r550433 - r550434;
        double r550436 = sqrt(r550435);
        double r550437 = r550436 / r550426;
        double r550438 = r550437 - r550427;
        double r550439 = -0.5;
        double r550440 = r550424 * r550439;
        double r550441 = r550432 ? r550438 : r550440;
        double r550442 = r550421 ? r550430 : r550441;
        return r550442;
}

Error

Bits error versus a

Bits error versus b_2

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_2 < -8.856808865537945e+146

    1. Initial program 58.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified58.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub58.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]
    5. Taylor expanded around -inf 2.1

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -8.856808865537945e+146 < b_2 < 8.670930634061063e-143

    1. Initial program 10.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified10.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub10.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]

    if 8.670930634061063e-143 < b_2

    1. Initial program 49.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified49.9

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub50.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]
    5. Taylor expanded around inf 11.6

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.856808865537945 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 8.670930634061063 \cdot 10^{-143}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019132 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))