Average Error: 34.8 → 10.3
Time: 6.9s
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 -2.3732770006881601 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.2699491303403745 \cdot 10^{143}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{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 -2.3732770006881601 \cdot 10^{-89}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r21293 = b_2;
        double r21294 = -r21293;
        double r21295 = r21293 * r21293;
        double r21296 = a;
        double r21297 = c;
        double r21298 = r21296 * r21297;
        double r21299 = r21295 - r21298;
        double r21300 = sqrt(r21299);
        double r21301 = r21294 - r21300;
        double r21302 = r21301 / r21296;
        return r21302;
}

double f(double a, double b_2, double c) {
        double r21303 = b_2;
        double r21304 = -2.37327700068816e-89;
        bool r21305 = r21303 <= r21304;
        double r21306 = -0.5;
        double r21307 = c;
        double r21308 = r21307 / r21303;
        double r21309 = r21306 * r21308;
        double r21310 = 1.2699491303403745e+143;
        bool r21311 = r21303 <= r21310;
        double r21312 = -r21303;
        double r21313 = r21303 * r21303;
        double r21314 = a;
        double r21315 = r21314 * r21307;
        double r21316 = r21313 - r21315;
        double r21317 = sqrt(r21316);
        double r21318 = r21312 - r21317;
        double r21319 = r21318 / r21314;
        double r21320 = -2.0;
        double r21321 = r21303 / r21314;
        double r21322 = r21320 * r21321;
        double r21323 = r21311 ? r21319 : r21322;
        double r21324 = r21305 ? r21309 : r21323;
        return r21324;
}

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 < -2.37327700068816e-89

    1. Initial program 52.5

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

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

    if -2.37327700068816e-89 < b_2 < 1.2699491303403745e+143

    1. Initial program 12.5

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv12.6

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}}\]
    6. Applied div-inv12.6

      \[\leadsto \color{blue}{\left(-b_2\right) \cdot \frac{1}{a}} - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}\]
    7. Applied distribute-rgt-out--12.6

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

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

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

    if 1.2699491303403745e+143 < b_2

    1. Initial program 60.0

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv60.0

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}}\]
    6. Applied div-inv60.0

      \[\leadsto \color{blue}{\left(-b_2\right) \cdot \frac{1}{a}} - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}\]
    7. Applied distribute-rgt-out--60.0

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

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

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

Reproduce

herbie shell --seed 2020033 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))