Average Error: 33.6 → 6.6
Time: 7.4s
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.619515284789695 \cdot 10^{+148}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt{b_2 \cdot b_2 - c \cdot a}\\ \mathbf{if}\;b_2 \leq 3.794720303511745 \cdot 10^{-306}:\\ \;\;\;\;\frac{c}{t_0 - b_2}\\ \mathbf{elif}\;b_2 \leq 8.089389794080142 \cdot 10^{+92}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1, -b_2, -t_0\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\ \end{array}\\ \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.619515284789695 \cdot 10^{+148}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt{b_2 \cdot b_2 - c \cdot a}\\
\mathbf{if}\;b_2 \leq 3.794720303511745 \cdot 10^{-306}:\\
\;\;\;\;\frac{c}{t_0 - b_2}\\

\mathbf{elif}\;b_2 \leq 8.089389794080142 \cdot 10^{+92}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, -b_2, -t_0\right)}{a}\\

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


\end{array}\\


\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.619515284789695e+148)
   (* -0.5 (/ c b_2))
   (let* ((t_0 (sqrt (- (* b_2 b_2) (* c a)))))
     (if (<= b_2 3.794720303511745e-306)
       (/ c (- t_0 b_2))
       (if (<= b_2 8.089389794080142e+92)
         (/ (fma 1.0 (- b_2) (- t_0)) 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.619515284789695e+148) {
		tmp = -0.5 * (c / b_2);
	} else {
		double t_0 = sqrt((b_2 * b_2) - (c * a));
		double tmp_1;
		if (b_2 <= 3.794720303511745e-306) {
			tmp_1 = c / (t_0 - b_2);
		} else if (b_2 <= 8.089389794080142e+92) {
			tmp_1 = fma(1.0, -b_2, -t_0) / a;
		} else {
			tmp_1 = (-b_2 - b_2) / a;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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.6195152847896951e148

    1. Initial program 63.6

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

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

    if -6.6195152847896951e148 < b_2 < 3.79472030351174487e-306

    1. Initial program 33.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied clear-num_binary6433.9

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{a}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}} \]
    7. Taylor expanded in a around 0 7.8

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

    if 3.79472030351174487e-306 < b_2 < 8.08938979408014236e92

    1. Initial program 9.4

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

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

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

    if 8.08938979408014236e92 < b_2

    1. Initial program 43.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -6.619515284789695 \cdot 10^{+148}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 3.794720303511745 \cdot 10^{-306}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 8.089389794080142 \cdot 10^{+92}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1, -b_2, -\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\ \end{array} \]

Reproduce

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