Average Error: 34.5 → 6.7
Time: 9.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 -1.02458994604675516 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.87487110304695476 \cdot 10^{-219}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 9.3479963141541371 \cdot 10^{42}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \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 -1.02458994604675516 \cdot 10^{154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.87487110304695476 \cdot 10^{-219}:\\
\;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r91384 = b_2;
        double r91385 = -r91384;
        double r91386 = r91384 * r91384;
        double r91387 = a;
        double r91388 = c;
        double r91389 = r91387 * r91388;
        double r91390 = r91386 - r91389;
        double r91391 = sqrt(r91390);
        double r91392 = r91385 - r91391;
        double r91393 = r91392 / r91387;
        return r91393;
}

double f(double a, double b_2, double c) {
        double r91394 = b_2;
        double r91395 = -1.0245899460467552e+154;
        bool r91396 = r91394 <= r91395;
        double r91397 = -0.5;
        double r91398 = c;
        double r91399 = r91398 / r91394;
        double r91400 = r91397 * r91399;
        double r91401 = 1.8748711030469548e-219;
        bool r91402 = r91394 <= r91401;
        double r91403 = a;
        double r91404 = r91398 * r91403;
        double r91405 = -r91404;
        double r91406 = fma(r91394, r91394, r91405);
        double r91407 = sqrt(r91406);
        double r91408 = r91407 - r91394;
        double r91409 = r91398 / r91408;
        double r91410 = 9.347996314154137e+42;
        bool r91411 = r91394 <= r91410;
        double r91412 = 1.0;
        double r91413 = -r91394;
        double r91414 = r91394 * r91394;
        double r91415 = r91403 * r91398;
        double r91416 = r91414 - r91415;
        double r91417 = sqrt(r91416);
        double r91418 = r91413 - r91417;
        double r91419 = r91403 / r91418;
        double r91420 = r91412 / r91419;
        double r91421 = 0.5;
        double r91422 = -2.0;
        double r91423 = r91394 / r91403;
        double r91424 = r91422 * r91423;
        double r91425 = fma(r91399, r91421, r91424);
        double r91426 = r91411 ? r91420 : r91425;
        double r91427 = r91402 ? r91409 : r91426;
        double r91428 = r91396 ? r91400 : r91427;
        return r91428;
}

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 < -1.0245899460467552e+154

    1. Initial program 64.0

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

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

    if -1.0245899460467552e+154 < b_2 < 1.8748711030469548e-219

    1. Initial program 32.0

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

      \[\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. Simplified15.5

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv15.5

      \[\leadsto \color{blue}{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2} \cdot \frac{1}{a}}\]
    8. Using strategy rm
    9. Applied associate-*l/13.9

      \[\leadsto \color{blue}{\frac{\left(b_2 \cdot \left(b_2 - b_2\right) + a \cdot c\right) \cdot \frac{1}{a}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}\]
    10. Simplified13.9

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(c, a, 0\right)}{a}}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\]
    11. Taylor expanded around 0 8.6

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

    if 1.8748711030469548e-219 < b_2 < 9.347996314154137e+42

    1. Initial program 8.7

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

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

    if 9.347996314154137e+42 < b_2

    1. Initial program 37.1

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.02458994604675516 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.87487110304695476 \cdot 10^{-219}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 9.3479963141541371 \cdot 10^{42}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +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))