Average Error: 33.7 → 10.1
Time: 11.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 -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - 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 -3.12428337420519208 \cdot 10^{57}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - 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 r14341 = b_2;
        double r14342 = -r14341;
        double r14343 = r14341 * r14341;
        double r14344 = a;
        double r14345 = c;
        double r14346 = r14344 * r14345;
        double r14347 = r14343 - r14346;
        double r14348 = sqrt(r14347);
        double r14349 = r14342 + r14348;
        double r14350 = r14349 / r14344;
        return r14350;
}

double f(double a, double b_2, double c) {
        double r14351 = b_2;
        double r14352 = -3.124283374205192e+57;
        bool r14353 = r14351 <= r14352;
        double r14354 = 0.5;
        double r14355 = c;
        double r14356 = r14355 / r14351;
        double r14357 = r14354 * r14356;
        double r14358 = 2.0;
        double r14359 = a;
        double r14360 = r14351 / r14359;
        double r14361 = r14358 * r14360;
        double r14362 = r14357 - r14361;
        double r14363 = 3.84613441880261e-81;
        bool r14364 = r14351 <= r14363;
        double r14365 = r14351 * r14351;
        double r14366 = r14359 * r14355;
        double r14367 = r14365 - r14366;
        double r14368 = sqrt(r14367);
        double r14369 = r14368 - r14351;
        double r14370 = r14369 / r14359;
        double r14371 = -0.5;
        double r14372 = r14371 * r14356;
        double r14373 = r14364 ? r14370 : r14372;
        double r14374 = r14353 ? r14362 : r14373;
        return r14374;
}

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 < -3.124283374205192e+57

    1. Initial program 39.4

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

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

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

    if -3.124283374205192e+57 < b_2 < 3.84613441880261e-81

    1. Initial program 12.7

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

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

      \[\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-inv12.7

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

    if 3.84613441880261e-81 < b_2

    1. Initial program 52.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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