Average Error: 34.2 → 10.0
Time: 4.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 -9.66563711558993385 \cdot 10^{-69}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 9.1585291365273219 \cdot 10^{122}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;{\left(-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 -9.66563711558993385 \cdot 10^{-69}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 9.1585291365273219 \cdot 10^{122}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r150176 = b_2;
        double r150177 = -r150176;
        double r150178 = r150176 * r150176;
        double r150179 = a;
        double r150180 = c;
        double r150181 = r150179 * r150180;
        double r150182 = r150178 - r150181;
        double r150183 = sqrt(r150182);
        double r150184 = r150177 - r150183;
        double r150185 = r150184 / r150179;
        return r150185;
}

double f(double a, double b_2, double c) {
        double r150186 = b_2;
        double r150187 = -9.665637115589934e-69;
        bool r150188 = r150186 <= r150187;
        double r150189 = -0.5;
        double r150190 = c;
        double r150191 = r150190 / r150186;
        double r150192 = r150189 * r150191;
        double r150193 = 9.158529136527322e+122;
        bool r150194 = r150186 <= r150193;
        double r150195 = -r150186;
        double r150196 = a;
        double r150197 = r150195 / r150196;
        double r150198 = r150186 * r150186;
        double r150199 = r150196 * r150190;
        double r150200 = r150198 - r150199;
        double r150201 = sqrt(r150200);
        double r150202 = r150201 / r150196;
        double r150203 = r150197 - r150202;
        double r150204 = -2.0;
        double r150205 = r150186 / r150196;
        double r150206 = r150204 * r150205;
        double r150207 = 1.0;
        double r150208 = pow(r150206, r150207);
        double r150209 = r150194 ? r150203 : r150208;
        double r150210 = r150188 ? r150192 : r150209;
        return r150210;
}

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 < -9.665637115589934e-69

    1. Initial program 53.8

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

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

    if -9.665637115589934e-69 < b_2 < 9.158529136527322e+122

    1. Initial program 13.0

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]

    if 9.158529136527322e+122 < b_2

    1. Initial program 53.1

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

      \[\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 pow153.2

      \[\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 pow153.2

      \[\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-down53.2

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

      \[\leadsto {\color{blue}{\left(\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\right)}}^{1}\]
    9. Using strategy rm
    10. Applied clear-num53.2

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

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

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

Reproduce

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