Average Error: 33.3 → 6.3
Time: 49.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 -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 r21483241 = b_2;
        double r21483242 = -r21483241;
        double r21483243 = r21483241 * r21483241;
        double r21483244 = a;
        double r21483245 = c;
        double r21483246 = r21483244 * r21483245;
        double r21483247 = r21483243 - r21483246;
        double r21483248 = sqrt(r21483247);
        double r21483249 = r21483242 - r21483248;
        double r21483250 = r21483249 / r21483244;
        return r21483250;
}

double f(double a, double b_2, double c) {
        double r21483251 = b_2;
        double r21483252 = -3.5881437021072993e+120;
        bool r21483253 = r21483251 <= r21483252;
        double r21483254 = -0.5;
        double r21483255 = c;
        double r21483256 = r21483255 / r21483251;
        double r21483257 = r21483254 * r21483256;
        double r21483258 = 3.3959730543616343e-248;
        bool r21483259 = r21483251 <= r21483258;
        double r21483260 = a;
        double r21483261 = r21483255 * r21483260;
        double r21483262 = -r21483261;
        double r21483263 = fma(r21483251, r21483251, r21483262);
        double r21483264 = sqrt(r21483263);
        double r21483265 = r21483264 - r21483251;
        double r21483266 = r21483255 / r21483265;
        double r21483267 = 1.0624845082926748e+132;
        bool r21483268 = r21483251 <= r21483267;
        double r21483269 = -r21483251;
        double r21483270 = r21483251 * r21483251;
        double r21483271 = r21483270 - r21483261;
        double r21483272 = sqrt(r21483271);
        double r21483273 = r21483269 - r21483272;
        double r21483274 = r21483273 / r21483260;
        double r21483275 = r21483251 / r21483260;
        double r21483276 = -2.0;
        double r21483277 = r21483275 * r21483276;
        double r21483278 = r21483268 ? r21483274 : r21483277;
        double r21483279 = r21483259 ? r21483266 : r21483278;
        double r21483280 = r21483253 ? r21483257 : r21483279;
        return r21483280;
}

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 "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))