Average Error: 33.4 → 9.9
Time: 20.0s
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 -1.056361093164439 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.326372645943808 \cdot 10^{-74}:\\ \;\;\;\;\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 -1.056361093164439 \cdot 10^{+152}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 2.326372645943808 \cdot 10^{-74}:\\
\;\;\;\;\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 r479539 = b_2;
        double r479540 = -r479539;
        double r479541 = r479539 * r479539;
        double r479542 = a;
        double r479543 = c;
        double r479544 = r479542 * r479543;
        double r479545 = r479541 - r479544;
        double r479546 = sqrt(r479545);
        double r479547 = r479540 + r479546;
        double r479548 = r479547 / r479542;
        return r479548;
}

double f(double a, double b_2, double c) {
        double r479549 = b_2;
        double r479550 = -1.056361093164439e+152;
        bool r479551 = r479549 <= r479550;
        double r479552 = 0.5;
        double r479553 = c;
        double r479554 = r479553 / r479549;
        double r479555 = r479552 * r479554;
        double r479556 = a;
        double r479557 = r479549 / r479556;
        double r479558 = 2.0;
        double r479559 = r479557 * r479558;
        double r479560 = r479555 - r479559;
        double r479561 = 2.326372645943808e-74;
        bool r479562 = r479549 <= r479561;
        double r479563 = r479549 * r479549;
        double r479564 = r479553 * r479556;
        double r479565 = r479563 - r479564;
        double r479566 = sqrt(r479565);
        double r479567 = r479566 - r479549;
        double r479568 = r479567 / r479556;
        double r479569 = -0.5;
        double r479570 = r479554 * r479569;
        double r479571 = r479562 ? r479568 : r479570;
        double r479572 = r479551 ? r479560 : r479571;
        return r479572;
}

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 < -1.056361093164439e+152

    1. Initial program 59.8

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

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

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

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

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

    if -1.056361093164439e+152 < b_2 < 2.326372645943808e-74

    1. Initial program 12.3

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

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

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

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

    if 2.326372645943808e-74 < b_2

    1. Initial program 52.5

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

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

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

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

      \[\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 -1.056361093164439 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.326372645943808 \cdot 10^{-74}:\\ \;\;\;\;\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 2019151 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))