Average Error: 34.1 → 10.2
Time: 16.8s
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 -17117282807329.436:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -2.321160141968036 \cdot 10^{-95}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{a}\\ \mathbf{elif}\;b_2 \leq -7.858266012356773 \cdot 10^{-121}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2}{-\frac{c}{b_2}}\right)}\\ \mathbf{elif}\;b_2 \leq 3.6266309301276617 \cdot 10^{+142}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \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 -17117282807329.436:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq -2.321160141968036 \cdot 10^{-95}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{a}\\

\mathbf{elif}\;b_2 \leq -7.858266012356773 \cdot 10^{-121}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2}{-\frac{c}{b_2}}\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\


\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 -17117282807329.436)
   (* -0.5 (/ c b_2))
   (if (<= b_2 -2.321160141968036e-95)
     (/ (/ (* c a) (- (hypot (sqrt (- (* c a))) b_2) b_2)) a)
     (if (<= b_2 -7.858266012356773e-121)
       (/ 1.0 (fma 0.5 (/ a b_2) (/ 2.0 (- (/ c b_2)))))
       (if (<= b_2 3.6266309301276617e+142)
         (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
         (fma 0.5 (/ c b_2) (* -2.0 (/ 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 <= -17117282807329.436) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= -2.321160141968036e-95) {
		tmp = ((c * a) / (hypot(sqrt(-(c * a)), b_2) - b_2)) / a;
	} else if (b_2 <= -7.858266012356773e-121) {
		tmp = 1.0 / fma(0.5, (a / b_2), (2.0 / -(c / b_2)));
	} else if (b_2 <= 3.6266309301276617e+142) {
		tmp = (-b_2 - sqrt((b_2 * b_2) - (c * a))) / a;
	} else {
		tmp = fma(0.5, (c / b_2), (-2.0 * (b_2 / a)));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 5 regimes
  2. if b_2 < -17117282807329.4355

    1. Initial program 56.4

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

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

    if -17117282807329.4355 < b_2 < -2.3211601419680362e-95

    1. Initial program 38.9

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

      \[\leadsto \frac{\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}}}}{a} \]
    3. Simplified17.0

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

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

    if -2.3211601419680362e-95 < b_2 < -7.8582660123567727e-121

    1. Initial program 27.7

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}}} \]
    4. Taylor expanded in b_2 around -inf 57.5

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot \frac{a}{b_2} + 2 \cdot \frac{a \cdot b_2}{{\left(\sqrt{-c \cdot a}\right)}^{2}}}} \]
    5. Simplified39.8

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

    if -7.8582660123567727e-121 < b_2 < 3.62663093012766167e142

    1. Initial program 11.0

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

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

    if 3.62663093012766167e142 < b_2

    1. Initial program 57.6

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}} \]
    3. Simplified2.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification10.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -17117282807329.436:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -2.321160141968036 \cdot 10^{-95}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{a}\\ \mathbf{elif}\;b_2 \leq -7.858266012356773 \cdot 10^{-121}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2}{-\frac{c}{b_2}}\right)}\\ \mathbf{elif}\;b_2 \leq 3.6266309301276617 \cdot 10^{+142}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array} \]

Reproduce

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