Average Error: 33.2 → 6.8
Time: 53.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 -4.089583723461392 \cdot 10^{+87}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.436990347475487 \cdot 10^{-257}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.9372043075778505 \cdot 10^{+88}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]
double f(double a, double b_2, double c) {
        double r2255380 = b_2;
        double r2255381 = -r2255380;
        double r2255382 = r2255380 * r2255380;
        double r2255383 = a;
        double r2255384 = c;
        double r2255385 = r2255383 * r2255384;
        double r2255386 = r2255382 - r2255385;
        double r2255387 = sqrt(r2255386);
        double r2255388 = r2255381 - r2255387;
        double r2255389 = r2255388 / r2255383;
        return r2255389;
}

double f(double a, double b_2, double c) {
        double r2255390 = b_2;
        double r2255391 = -4.089583723461392e+87;
        bool r2255392 = r2255390 <= r2255391;
        double r2255393 = -0.5;
        double r2255394 = c;
        double r2255395 = r2255394 / r2255390;
        double r2255396 = r2255393 * r2255395;
        double r2255397 = -2.436990347475487e-257;
        bool r2255398 = r2255390 <= r2255397;
        double r2255399 = r2255390 * r2255390;
        double r2255400 = a;
        double r2255401 = r2255400 * r2255394;
        double r2255402 = r2255399 - r2255401;
        double r2255403 = sqrt(r2255402);
        double r2255404 = r2255403 - r2255390;
        double r2255405 = r2255394 / r2255404;
        double r2255406 = 1.9372043075778505e+88;
        bool r2255407 = r2255390 <= r2255406;
        double r2255408 = -r2255390;
        double r2255409 = r2255408 - r2255403;
        double r2255410 = 1.0;
        double r2255411 = r2255410 / r2255400;
        double r2255412 = r2255409 * r2255411;
        double r2255413 = -2.0;
        double r2255414 = r2255390 / r2255400;
        double r2255415 = r2255413 * r2255414;
        double r2255416 = r2255407 ? r2255412 : r2255415;
        double r2255417 = r2255398 ? r2255405 : r2255416;
        double r2255418 = r2255392 ? r2255396 : r2255417;
        return r2255418;
}

\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -4.089583723461392 \cdot 10^{+87}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.436990347475487 \cdot 10^{-257}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

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

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

\end{array}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -4.089583723461392e+87

    1. Initial program 58.2

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

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

    if -4.089583723461392e+87 < b_2 < -2.436990347475487e-257

    1. Initial program 33.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--33.2

      \[\leadsto \frac{\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}}}}{a}\]
    4. Applied associate-/l/37.8

      \[\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}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    5. Simplified20.6

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Using strategy rm
    7. Applied times-frac7.9

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

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

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

    if -2.436990347475487e-257 < b_2 < 1.9372043075778505e+88

    1. Initial program 9.9

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

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

    if 1.9372043075778505e+88 < b_2

    1. Initial program 41.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--61.0

      \[\leadsto \frac{\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}}}}{a}\]
    4. Applied associate-/l/61.3

      \[\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}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    5. Simplified61.5

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Taylor expanded around 0 4.4

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.089583723461392 \cdot 10^{+87}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.436990347475487 \cdot 10^{-257}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.9372043075778505 \cdot 10^{+88}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019101 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))