Average Error: 33.3 → 6.0
Time: 1.1m
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.909589459766455 \cdot 10^{+149}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.1973583843642258 \cdot 10^{-287}:\\ \;\;\;\;\frac{c}{\sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.0185417924042504 \cdot 10^{+119}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{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.909589459766455 \cdot 10^{+149}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.1973583843642258 \cdot 10^{-287}:\\
\;\;\;\;\frac{c}{\sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*} + \left(-b_2\right)}\\

\mathbf{elif}\;b_2 \le 1.0185417924042504 \cdot 10^{+119}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*}}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r8801069 = b_2;
        double r8801070 = -r8801069;
        double r8801071 = r8801069 * r8801069;
        double r8801072 = a;
        double r8801073 = c;
        double r8801074 = r8801072 * r8801073;
        double r8801075 = r8801071 - r8801074;
        double r8801076 = sqrt(r8801075);
        double r8801077 = r8801070 - r8801076;
        double r8801078 = r8801077 / r8801072;
        return r8801078;
}

double f(double a, double b_2, double c) {
        double r8801079 = b_2;
        double r8801080 = -6.909589459766455e+149;
        bool r8801081 = r8801079 <= r8801080;
        double r8801082 = -0.5;
        double r8801083 = c;
        double r8801084 = r8801083 / r8801079;
        double r8801085 = r8801082 * r8801084;
        double r8801086 = -1.1973583843642258e-287;
        bool r8801087 = r8801079 <= r8801086;
        double r8801088 = a;
        double r8801089 = r8801083 * r8801088;
        double r8801090 = -r8801089;
        double r8801091 = fma(r8801079, r8801079, r8801090);
        double r8801092 = sqrt(r8801091);
        double r8801093 = -r8801079;
        double r8801094 = r8801092 + r8801093;
        double r8801095 = r8801083 / r8801094;
        double r8801096 = 1.0185417924042504e+119;
        bool r8801097 = r8801079 <= r8801096;
        double r8801098 = r8801093 - r8801092;
        double r8801099 = r8801098 / r8801088;
        double r8801100 = 0.5;
        double r8801101 = r8801079 / r8801083;
        double r8801102 = r8801088 / r8801101;
        double r8801103 = -2.0;
        double r8801104 = r8801079 * r8801103;
        double r8801105 = fma(r8801100, r8801102, r8801104);
        double r8801106 = r8801105 / r8801088;
        double r8801107 = r8801097 ? r8801099 : r8801106;
        double r8801108 = r8801087 ? r8801095 : r8801107;
        double r8801109 = r8801081 ? r8801085 : r8801108;
        return r8801109;
}

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 < -6.909589459766455e+149

    1. Initial program 62.5

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

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

    if -6.909589459766455e+149 < b_2 < -1.1973583843642258e-287

    1. Initial program 34.4

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}}}{a}\]
    4. Using strategy rm
    5. Applied div-inv34.4

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}\right) \cdot \frac{1}{a}}\]
    6. Using strategy rm
    7. Applied flip--34.5

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*} \cdot \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}}{\left(-b_2\right) + \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}}} \cdot \frac{1}{a}\]
    8. Applied associate-*l/34.5

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*} \cdot \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}}}\]
    9. Simplified13.8

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{a}}}{\left(-b_2\right) + \sqrt{(b_2 \cdot b_2 + \left(-a \cdot c\right))_*}}\]
    10. Taylor expanded around -inf 6.9

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

    if -1.1973583843642258e-287 < b_2 < 1.0185417924042504e+119

    1. Initial program 8.4

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

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

    if 1.0185417924042504e+119 < b_2

    1. Initial program 50.9

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - 2 \cdot b_2}}{a}\]
    5. Simplified3.5

      \[\leadsto \frac{\color{blue}{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(-2 \cdot b_2\right))_*}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.909589459766455 \cdot 10^{+149}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.1973583843642258 \cdot 10^{-287}:\\ \;\;\;\;\frac{c}{\sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.0185417924042504 \cdot 10^{+119}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{(b_2 \cdot b_2 + \left(-c \cdot a\right))_*}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \end{array}\]

Reproduce

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