Average Error: 33.9 → 10.8
Time: 9.2s
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.9315373378557038 \cdot 10^{-23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.77017414835012383 \cdot 10^{70}:\\ \;\;\;\;{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\ \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.9315373378557038 \cdot 10^{-23}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\

\end{array}
double f(double a, double b_2, double c) {
        double r391 = b_2;
        double r392 = -r391;
        double r393 = r391 * r391;
        double r394 = a;
        double r395 = c;
        double r396 = r394 * r395;
        double r397 = r393 - r396;
        double r398 = sqrt(r397);
        double r399 = r392 - r398;
        double r400 = r399 / r394;
        return r400;
}

double f(double a, double b_2, double c) {
        double r401 = b_2;
        double r402 = -6.931537337855704e-23;
        bool r403 = r401 <= r402;
        double r404 = -0.5;
        double r405 = c;
        double r406 = r405 / r401;
        double r407 = r404 * r406;
        double r408 = 1.7701741483501238e+70;
        bool r409 = r401 <= r408;
        double r410 = -r401;
        double r411 = r401 * r401;
        double r412 = a;
        double r413 = r412 * r405;
        double r414 = r411 - r413;
        double r415 = sqrt(r414);
        double r416 = r410 - r415;
        double r417 = r416 / r412;
        double r418 = 1.0;
        double r419 = pow(r417, r418);
        double r420 = 0.5;
        double r421 = r420 * r406;
        double r422 = 2.0;
        double r423 = r401 / r412;
        double r424 = r422 * r423;
        double r425 = r421 - r424;
        double r426 = pow(r425, r418);
        double r427 = r409 ? r419 : r426;
        double r428 = r403 ? r407 : r427;
        return r428;
}

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.931537337855704e-23

    1. Initial program 54.3

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

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

    if -6.931537337855704e-23 < b_2 < 1.7701741483501238e+70

    1. Initial program 15.5

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

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

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down15.6

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

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

    if 1.7701741483501238e+70 < b_2

    1. Initial program 41.6

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

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

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down41.6

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

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

      \[\leadsto {\color{blue}{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.9315373378557038 \cdot 10^{-23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.77017414835012383 \cdot 10^{70}:\\ \;\;\;\;{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}^{1}\\ \end{array}\]

Reproduce

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