Average Error: 33.8 → 10.2
Time: 20.5s
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.569494919068124572690421335939486791404 \cdot 10^{-64}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.8653816703769607550753035783606354728 \cdot 10^{117}:\\ \;\;\;\;\frac{-\left(\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2\right)}{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 -2.569494919068124572690421335939486791404 \cdot 10^{-64}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r1108386 = b_2;
        double r1108387 = -r1108386;
        double r1108388 = r1108386 * r1108386;
        double r1108389 = a;
        double r1108390 = c;
        double r1108391 = r1108389 * r1108390;
        double r1108392 = r1108388 - r1108391;
        double r1108393 = sqrt(r1108392);
        double r1108394 = r1108387 - r1108393;
        double r1108395 = r1108394 / r1108389;
        return r1108395;
}

double f(double a, double b_2, double c) {
        double r1108396 = b_2;
        double r1108397 = -2.5694949190681246e-64;
        bool r1108398 = r1108396 <= r1108397;
        double r1108399 = -0.5;
        double r1108400 = c;
        double r1108401 = r1108400 / r1108396;
        double r1108402 = r1108399 * r1108401;
        double r1108403 = 2.865381670376961e+117;
        bool r1108404 = r1108396 <= r1108403;
        double r1108405 = r1108396 * r1108396;
        double r1108406 = a;
        double r1108407 = r1108400 * r1108406;
        double r1108408 = r1108405 - r1108407;
        double r1108409 = sqrt(r1108408);
        double r1108410 = r1108409 + r1108396;
        double r1108411 = -r1108410;
        double r1108412 = r1108411 / r1108406;
        double r1108413 = r1108396 / r1108406;
        double r1108414 = -2.0;
        double r1108415 = r1108413 * r1108414;
        double r1108416 = r1108404 ? r1108412 : r1108415;
        double r1108417 = r1108398 ? r1108402 : r1108416;
        return r1108417;
}

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.5694949190681246e-64

    1. Initial program 53.1

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

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

    if -2.5694949190681246e-64 < b_2 < 2.865381670376961e+117

    1. Initial program 13.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv13.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 associate-*r/13.1

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

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

    if 2.865381670376961e+117 < b_2

    1. Initial program 52.0

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

      \[\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 associate-*r/52.0

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot 1}{a}}\]
    6. Simplified52.0

      \[\leadsto \frac{\color{blue}{-\left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}{a}\]
    7. Using strategy rm
    8. Applied neg-mul-152.0

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

      \[\leadsto \color{blue}{\frac{-1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}\]
    10. Taylor expanded around 0 3.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.569494919068124572690421335939486791404 \cdot 10^{-64}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.8653816703769607550753035783606354728 \cdot 10^{117}:\\ \;\;\;\;\frac{-\left(\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \end{array}\]

Reproduce

herbie shell --seed 2019169 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))