Average Error: 34.5 → 10.4
Time: 11.7s
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.164889649843396 \cdot 10^{-82}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \mathbf{elif}\;b_2 \leq 1.93458229061205 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)}}{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 -2.164889649843396 \cdot 10^{-82}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\

\mathbf{elif}\;b_2 \leq 1.93458229061205 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)}}{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 -2.164889649843396e-82)
   (* (/ c b_2) -0.5)
   (if (<= b_2 1.93458229061205e+34)
     (/ (- (- b_2) (sqrt (fma 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 <= -2.164889649843396e-82) {
		tmp = (c / b_2) * -0.5;
	} else if (b_2 <= 1.93458229061205e+34) {
		tmp = (-b_2 - sqrt(fma(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 3 regimes
  2. if b_2 < -2.1648896498433961e-82

    1. Initial program 52.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Using strategy rm
    3. Applied clear-num_binary6452.7

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{\left(\sqrt{-c \cdot a}\right)}^{2}}{a \cdot b_2}} \]
    6. Simplified9.4

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

    if -2.1648896498433961e-82 < b_2 < 1.93458229061205e34

    1. Initial program 13.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Using strategy rm
    3. Applied fma-neg_binary6413.7

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

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

    if 1.93458229061205e34 < b_2

    1. Initial program 37.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.164889649843396 \cdot 10^{-82}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \mathbf{elif}\;b_2 \leq 1.93458229061205 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\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 2021210 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))