Average Error: 34.2 → 8.6
Time: 12.5s
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.05249693088806959 \cdot 10^{141}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.2009669688403957 \cdot 10^{-265}:\\ \;\;\;\;\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 4.00290224310907 \cdot 10^{44}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_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.05249693088806959 \cdot 10^{141}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le 2.2009669688403957 \cdot 10^{-265}:\\
\;\;\;\;\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\

\mathbf{elif}\;b_2 \le 4.00290224310907 \cdot 10^{44}:\\
\;\;\;\;\frac{\frac{a \cdot c}{a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r13697 = b_2;
        double r13698 = -r13697;
        double r13699 = r13697 * r13697;
        double r13700 = a;
        double r13701 = c;
        double r13702 = r13700 * r13701;
        double r13703 = r13699 - r13702;
        double r13704 = sqrt(r13703);
        double r13705 = r13698 + r13704;
        double r13706 = r13705 / r13700;
        return r13706;
}

double f(double a, double b_2, double c) {
        double r13707 = b_2;
        double r13708 = -1.0524969308880696e+141;
        bool r13709 = r13707 <= r13708;
        double r13710 = 0.5;
        double r13711 = c;
        double r13712 = r13711 / r13707;
        double r13713 = r13710 * r13712;
        double r13714 = 2.0;
        double r13715 = a;
        double r13716 = r13707 / r13715;
        double r13717 = r13714 * r13716;
        double r13718 = r13713 - r13717;
        double r13719 = 2.2009669688403957e-265;
        bool r13720 = r13707 <= r13719;
        double r13721 = -r13707;
        double r13722 = r13707 * r13707;
        double r13723 = r13715 * r13711;
        double r13724 = r13722 - r13723;
        double r13725 = sqrt(r13724);
        double r13726 = r13721 + r13725;
        double r13727 = 1.0;
        double r13728 = r13727 / r13715;
        double r13729 = r13726 * r13728;
        double r13730 = 4.0029022431090705e+44;
        bool r13731 = r13707 <= r13730;
        double r13732 = r13723 / r13715;
        double r13733 = r13721 - r13725;
        double r13734 = r13732 / r13733;
        double r13735 = -0.5;
        double r13736 = r13735 * r13712;
        double r13737 = r13731 ? r13734 : r13736;
        double r13738 = r13720 ? r13729 : r13737;
        double r13739 = r13709 ? r13718 : r13738;
        return r13739;
}

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 4 regimes
  2. if b_2 < -1.0524969308880696e+141

    1. Initial program 58.5

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

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

    if -1.0524969308880696e+141 < b_2 < 2.2009669688403957e-265

    1. Initial program 9.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv9.8

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

    if 2.2009669688403957e-265 < b_2 < 4.0029022431090705e+44

    1. Initial program 29.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv29.6

      \[\leadsto \color{blue}{\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Using strategy rm
    5. Applied flip-+29.6

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/29.7

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified16.4

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c + 0}{a}}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\]

    if 4.0029022431090705e+44 < b_2

    1. Initial program 56.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.05249693088806959 \cdot 10^{141}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.2009669688403957 \cdot 10^{-265}:\\ \;\;\;\;\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 4.00290224310907 \cdot 10^{44}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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