Average Error: 33.3 → 10.0
Time: 29.1s
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 -4.82289647433212 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.3930366094323856 \cdot 10^{-68}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 -4.82289647433212 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 2.3930366094323856 \cdot 10^{-68}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 r684453 = b_2;
        double r684454 = -r684453;
        double r684455 = r684453 * r684453;
        double r684456 = a;
        double r684457 = c;
        double r684458 = r684456 * r684457;
        double r684459 = r684455 - r684458;
        double r684460 = sqrt(r684459);
        double r684461 = r684454 + r684460;
        double r684462 = r684461 / r684456;
        return r684462;
}

double f(double a, double b_2, double c) {
        double r684463 = b_2;
        double r684464 = -4.82289647433212e+153;
        bool r684465 = r684463 <= r684464;
        double r684466 = 0.5;
        double r684467 = c;
        double r684468 = r684467 / r684463;
        double r684469 = r684466 * r684468;
        double r684470 = a;
        double r684471 = r684463 / r684470;
        double r684472 = 2.0;
        double r684473 = r684471 * r684472;
        double r684474 = r684469 - r684473;
        double r684475 = 2.3930366094323856e-68;
        bool r684476 = r684463 <= r684475;
        double r684477 = r684463 * r684463;
        double r684478 = r684467 * r684470;
        double r684479 = r684477 - r684478;
        double r684480 = sqrt(r684479);
        double r684481 = r684480 - r684463;
        double r684482 = r684481 / r684470;
        double r684483 = -0.5;
        double r684484 = r684468 * r684483;
        double r684485 = r684476 ? r684482 : r684484;
        double r684486 = r684465 ? r684474 : r684485;
        return r684486;
}

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 < -4.82289647433212e+153

    1. Initial program 60.9

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified60.9

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

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

    if -4.82289647433212e+153 < b_2 < 2.3930366094323856e-68

    1. Initial program 12.4

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified12.4

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

    if 2.3930366094323856e-68 < b_2

    1. Initial program 52.2

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified52.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.82289647433212 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.3930366094323856 \cdot 10^{-68}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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