Average Error: 33.3 → 6.3
Time: 51.8s
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.5881437021072993 \cdot 10^{+120}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.3959730543616343 \cdot 10^{-248}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, \left(-c \cdot a\right)\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.0624845082926748 \cdot 10^{+132}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -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.5881437021072993 \cdot 10^{+120}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2168380 = b_2;
        double r2168381 = -r2168380;
        double r2168382 = r2168380 * r2168380;
        double r2168383 = a;
        double r2168384 = c;
        double r2168385 = r2168383 * r2168384;
        double r2168386 = r2168382 - r2168385;
        double r2168387 = sqrt(r2168386);
        double r2168388 = r2168381 - r2168387;
        double r2168389 = r2168388 / r2168383;
        return r2168389;
}

double f(double a, double b_2, double c) {
        double r2168390 = b_2;
        double r2168391 = -3.5881437021072993e+120;
        bool r2168392 = r2168390 <= r2168391;
        double r2168393 = -0.5;
        double r2168394 = c;
        double r2168395 = r2168394 / r2168390;
        double r2168396 = r2168393 * r2168395;
        double r2168397 = 3.3959730543616343e-248;
        bool r2168398 = r2168390 <= r2168397;
        double r2168399 = a;
        double r2168400 = r2168394 * r2168399;
        double r2168401 = -r2168400;
        double r2168402 = fma(r2168390, r2168390, r2168401);
        double r2168403 = sqrt(r2168402);
        double r2168404 = r2168403 - r2168390;
        double r2168405 = r2168394 / r2168404;
        double r2168406 = 1.0624845082926748e+132;
        bool r2168407 = r2168390 <= r2168406;
        double r2168408 = -r2168390;
        double r2168409 = r2168390 * r2168390;
        double r2168410 = r2168409 - r2168400;
        double r2168411 = sqrt(r2168410);
        double r2168412 = r2168408 - r2168411;
        double r2168413 = r2168412 / r2168399;
        double r2168414 = r2168390 / r2168399;
        double r2168415 = -2.0;
        double r2168416 = r2168414 * r2168415;
        double r2168417 = r2168407 ? r2168413 : r2168416;
        double r2168418 = r2168398 ? r2168405 : r2168417;
        double r2168419 = r2168392 ? r2168396 : r2168418;
        return r2168419;
}

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 < -3.5881437021072993e+120

    1. Initial program 59.4

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

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

    if -3.5881437021072993e+120 < b_2 < 3.3959730543616343e-248

    1. Initial program 30.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--31.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. Applied associate-/l/36.1

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    10. Using strategy rm
    11. Applied fma-neg8.7

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

    if 3.3959730543616343e-248 < b_2 < 1.0624845082926748e+132

    1. Initial program 7.9

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

    if 1.0624845082926748e+132 < b_2

    1. Initial program 53.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--62.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. Applied associate-/l/62.2

      \[\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. Simplified62.4

      \[\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 3.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.5881437021072993 \cdot 10^{+120}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.3959730543616343 \cdot 10^{-248}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, \left(-c \cdot a\right)\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.0624845082926748 \cdot 10^{+132}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \end{array}\]

Reproduce

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