Average Error: 34.7 → 10.4
Time: 11.3s
Precision: binary64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -6.242469537217322 \cdot 10^{-119}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 6.214809179847051 \cdot 10^{+76}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - 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 \leq -6.242469537217322 \cdot 10^{-119}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 6.214809179847051 \cdot 10^{+76}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\


\end{array}
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -6.242469537217322e-119)
   (* -0.5 (/ c b_2))
   (if (<= b_2 6.214809179847051e+76)
     (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
     (/ (- (- b_2) b_2) a))))
double code(double a, double b_2, double c) {
	return (-b_2 - sqrt((b_2 * b_2) - (a * c))) / a;
}
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -6.242469537217322e-119) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 6.214809179847051e+76) {
		tmp = (-b_2 - sqrt((b_2 * b_2) - (c * a))) / a;
	} else {
		tmp = (-b_2 - b_2) / a;
	}
	return tmp;
}

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 < -6.2424695372173217e-119

    1. Initial program 51.8

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

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

    if -6.2424695372173217e-119 < b_2 < 6.2148091798470513e76

    1. Initial program 12.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied *-un-lft-identity_binary6412.2

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{1 \cdot \left(b_2 \cdot b_2 - a \cdot c\right)}}}{a} \]
    3. Applied sqrt-prod_binary6412.2

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{1} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a} \]
    4. Applied cancel-sign-sub-inv_binary6412.2

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

    if 6.2148091798470513e76 < b_2

    1. Initial program 43.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -6.242469537217322 \cdot 10^{-119}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 6.214809179847051 \cdot 10^{+76}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\ \end{array} \]

Reproduce

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