Average Error: 33.8 → 9.4
Time: 8.9s
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 -2.0523858676494354 \cdot 10^{-52}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)\\ \mathbf{if}\;b_2 \leq 2.6030463307926315 \cdot 10^{-305}:\\ \;\;\;\;\frac{c}{t_0 - b_2}\\ \mathbf{elif}\;b_2 \leq 1003851693548.0198:\\ \;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \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 -2.0523858676494354 \cdot 10^{-52}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)\\
\mathbf{if}\;b_2 \leq 2.6030463307926315 \cdot 10^{-305}:\\
\;\;\;\;\frac{c}{t_0 - b_2}\\

\mathbf{elif}\;b_2 \leq 1003851693548.0198:\\
\;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\

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


\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 -2.0523858676494354e-52)
   (* -0.5 (/ c b_2))
   (let* ((t_0 (hypot (sqrt (- (* c a))) b_2)))
     (if (<= b_2 2.6030463307926315e-305)
       (/ c (- t_0 b_2))
       (if (<= b_2 1003851693548.0198)
         (/ (- (- b_2) t_0) 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 <= -2.0523858676494354e-52) {
		tmp = -0.5 * (c / b_2);
	} else {
		double t_0 = hypot(sqrt(-(c * a)), b_2);
		double tmp_1;
		if (b_2 <= 2.6030463307926315e-305) {
			tmp_1 = c / (t_0 - b_2);
		} else if (b_2 <= 1003851693548.0198) {
			tmp_1 = (-b_2 - t_0) / a;
		} else {
			tmp_1 = fma(0.5, (c / b_2), (-2.0 * (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 < -2.0523858676494354e-52

    1. Initial program 54.1

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

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

    if -2.0523858676494354e-52 < b_2 < 2.6030463307926315e-305

    1. Initial program 21.7

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

      \[\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.7

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

      \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}}{a} \]
    5. Applied *-un-lft-identity_binary6420.0

      \[\leadsto \frac{\frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}{\color{blue}{1 \cdot a}} \]
    6. Applied *-un-lft-identity_binary6420.0

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{c \cdot a}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}}}{1 \cdot a} \]
    7. Applied times-frac_binary6420.0

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

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

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

    if 2.6030463307926315e-305 < b_2 < 1003851693548.0198

    1. Initial program 9.8

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}}} \]
    4. Applied div-inv_binary6413.6

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}}} \]
    5. Applied add-cube-cbrt_binary6413.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{a \cdot \frac{1}{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}} \]
    6. Applied times-frac_binary6413.6

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

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

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)\right)} \]
    9. Applied associate-*l/_binary6413.4

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

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

    if 1003851693548.0198 < b_2

    1. Initial program 32.5

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

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

      \[\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.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.0523858676494354 \cdot 10^{-52}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.6030463307926315 \cdot 10^{-305}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 1003851693548.0198:\\ \;\;\;\;\frac{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right)}{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 2022055 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))