Average Error: 33.5 → 10.4
Time: 20.3s
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 -6.037409549902714 \cdot 10^{+148}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.9573510501313932 \cdot 10^{-67}:\\ \;\;\;\;\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 -6.037409549902714 \cdot 10^{+148}:\\
\;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 1.9573510501313932 \cdot 10^{-67}:\\
\;\;\;\;\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 r814006 = b_2;
        double r814007 = -r814006;
        double r814008 = r814006 * r814006;
        double r814009 = a;
        double r814010 = c;
        double r814011 = r814009 * r814010;
        double r814012 = r814008 - r814011;
        double r814013 = sqrt(r814012);
        double r814014 = r814007 + r814013;
        double r814015 = r814014 / r814009;
        return r814015;
}

double f(double a, double b_2, double c) {
        double r814016 = b_2;
        double r814017 = -6.037409549902714e+148;
        bool r814018 = r814016 <= r814017;
        double r814019 = c;
        double r814020 = r814019 / r814016;
        double r814021 = 2.0;
        double r814022 = r814020 / r814021;
        double r814023 = a;
        double r814024 = r814016 / r814023;
        double r814025 = r814024 * r814021;
        double r814026 = r814022 - r814025;
        double r814027 = 1.9573510501313932e-67;
        bool r814028 = r814016 <= r814027;
        double r814029 = r814016 * r814016;
        double r814030 = r814019 * r814023;
        double r814031 = r814029 - r814030;
        double r814032 = sqrt(r814031);
        double r814033 = r814032 - r814016;
        double r814034 = r814033 / r814023;
        double r814035 = -0.5;
        double r814036 = r814020 * r814035;
        double r814037 = r814028 ? r814034 : r814036;
        double r814038 = r814018 ? r814026 : r814037;
        return r814038;
}

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 < -6.037409549902714e+148

    1. Initial program 59.0

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied un-div-inv59.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    7. Using strategy rm
    8. Applied div-sub59.0

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

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

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

    if -6.037409549902714e+148 < b_2 < 1.9573510501313932e-67

    1. Initial program 13.2

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied un-div-inv13.2

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

    if 1.9573510501313932e-67 < b_2

    1. Initial program 51.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.037409549902714 \cdot 10^{+148}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.9573510501313932 \cdot 10^{-67}:\\ \;\;\;\;\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 2019163 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))