Average Error: 33.0 → 10.3
Time: 19.7s
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.615151909502748 \cdot 10^{-87}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.5387363548079373 \cdot 10^{+99}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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.615151909502748 \cdot 10^{-87}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 3.5387363548079373 \cdot 10^{+99}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r2095423 = b_2;
        double r2095424 = -r2095423;
        double r2095425 = r2095423 * r2095423;
        double r2095426 = a;
        double r2095427 = c;
        double r2095428 = r2095426 * r2095427;
        double r2095429 = r2095425 - r2095428;
        double r2095430 = sqrt(r2095429);
        double r2095431 = r2095424 - r2095430;
        double r2095432 = r2095431 / r2095426;
        return r2095432;
}

double f(double a, double b_2, double c) {
        double r2095433 = b_2;
        double r2095434 = -6.615151909502748e-87;
        bool r2095435 = r2095433 <= r2095434;
        double r2095436 = -0.5;
        double r2095437 = c;
        double r2095438 = r2095437 / r2095433;
        double r2095439 = r2095436 * r2095438;
        double r2095440 = 3.5387363548079373e+99;
        bool r2095441 = r2095433 <= r2095440;
        double r2095442 = -r2095433;
        double r2095443 = a;
        double r2095444 = r2095442 / r2095443;
        double r2095445 = r2095433 * r2095433;
        double r2095446 = r2095437 * r2095443;
        double r2095447 = r2095445 - r2095446;
        double r2095448 = sqrt(r2095447);
        double r2095449 = r2095448 / r2095443;
        double r2095450 = r2095444 - r2095449;
        double r2095451 = -2.0;
        double r2095452 = r2095433 / r2095443;
        double r2095453 = r2095451 * r2095452;
        double r2095454 = r2095441 ? r2095450 : r2095453;
        double r2095455 = r2095435 ? r2095439 : r2095454;
        return r2095455;
}

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.615151909502748e-87

    1. Initial program 52.0

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

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Taylor expanded around -inf 10.0

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

    if -6.615151909502748e-87 < b_2 < 3.5387363548079373e+99

    1. Initial program 12.7

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

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

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

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

    if 3.5387363548079373e+99 < b_2

    1. Initial program 44.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv44.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 un-div-inv44.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.615151909502748 \cdot 10^{-87}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.5387363548079373 \cdot 10^{+99}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019133 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))