Average Error: 30.5 → 9.2
Time: 8.2s
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 -1183068598468963.8:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -4.848180454524789 \cdot 10^{-132}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{a}\\ \mathbf{elif}\;b_2 \leq 2.671050891722767 \cdot 10^{+102}:\\ \;\;\;\;\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 -1183068598468963.8:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \leq 2.671050891722767 \cdot 10^{+102}:\\
\;\;\;\;\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 -1183068598468963.8)
   (* -0.5 (/ c b_2))
   (if (<= b_2 -4.848180454524789e-132)
     (/ (/ (* c a) (- (hypot (sqrt (- (* c a))) b_2) b_2)) a)
     (if (<= b_2 2.671050891722767e+102)
       (/ (- (- 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 <= -1183068598468963.8) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= -4.848180454524789e-132) {
		tmp = ((c * a) / (hypot(sqrt(-(c * a)), b_2) - b_2)) / a;
	} else if (b_2 <= 2.671050891722767e+102) {
		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 4 regimes
  2. if b_2 < -1183068598468963.75

    1. Initial program 55.2

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

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

    if -1183068598468963.75 < b_2 < -4.84818045452478885e-132

    1. Initial program 33.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied flip--_binary6433.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. Simplified16.1

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

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

    if -4.84818045452478885e-132 < b_2 < 2.6710508917227671e102

    1. Initial program 11.4

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

    if 2.6710508917227671e102 < b_2

    1. Initial program 30.2

      \[\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 4 regimes into one program.
  4. Final simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1183068598468963.8:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -4.848180454524789 \cdot 10^{-132}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{a}\\ \mathbf{elif}\;b_2 \leq 2.671050891722767 \cdot 10^{+102}:\\ \;\;\;\;\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 2022067 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))