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

\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{-1}{2} \cdot \frac{c}{b_2}\\

\end{array}
double f(double a, double b_2, double c) {
        double r814332 = b_2;
        double r814333 = -r814332;
        double r814334 = r814332 * r814332;
        double r814335 = a;
        double r814336 = c;
        double r814337 = r814335 * r814336;
        double r814338 = r814334 - r814337;
        double r814339 = sqrt(r814338);
        double r814340 = r814333 + r814339;
        double r814341 = r814340 / r814335;
        return r814341;
}

double f(double a, double b_2, double c) {
        double r814342 = b_2;
        double r814343 = -6.037409549902714e+148;
        bool r814344 = r814342 <= r814343;
        double r814345 = c;
        double r814346 = 2.0;
        double r814347 = r814346 * r814342;
        double r814348 = r814345 / r814347;
        double r814349 = a;
        double r814350 = r814342 / r814349;
        double r814351 = r814346 * r814350;
        double r814352 = r814348 - r814351;
        double r814353 = 1.9573510501313932e-67;
        bool r814354 = r814342 <= r814353;
        double r814355 = r814342 * r814342;
        double r814356 = r814345 * r814349;
        double r814357 = r814355 - r814356;
        double r814358 = sqrt(r814357);
        double r814359 = r814358 - r814342;
        double r814360 = r814359 / r814349;
        double r814361 = -0.5;
        double r814362 = r814345 / r814342;
        double r814363 = r814361 * r814362;
        double r814364 = r814354 ? r814360 : r814363;
        double r814365 = r814344 ? r814352 : r814364;
        return r814365;
}

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. Taylor expanded around -inf 1.9

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

      \[\leadsto \color{blue}{\frac{c}{2 \cdot b_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{c}{2 \cdot b_2} - 2 \cdot \frac{b_2}{a}\\ \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{-1}{2} \cdot \frac{c}{b_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))