Average Error: 34.2 → 8.4
Time: 13.0s
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 -22357588223804.316:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 3.470829932155455 \cdot 10^{-200}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 1.2798399534946243 \cdot 10^{+89}:\\ \;\;\;\;\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 -22357588223804.316:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \leq 1.2798399534946243 \cdot 10^{+89}:\\
\;\;\;\;\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 -22357588223804.316)
   (* -0.5 (/ c b_2))
   (if (<= b_2 3.470829932155455e-200)
     (/ c (- (hypot (sqrt (- (* c a))) b_2) b_2))
     (if (<= b_2 1.2798399534946243e+89)
       (/ (- (- 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 <= -22357588223804.316) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 3.470829932155455e-200) {
		tmp = c / (hypot(sqrt(-(c * a)), b_2) - b_2);
	} else if (b_2 <= 1.2798399534946243e+89) {
		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 < -22357588223804.3164

    1. Initial program 56.3

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

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

    if -22357588223804.3164 < b_2 < 3.4708299321554552e-200

    1. Initial program 24.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a} \]
    4. Simplified21.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_binary6421.0

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

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

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

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

    if 3.4708299321554552e-200 < b_2 < 1.27983995349462433e89

    1. Initial program 7.5

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

    if 1.27983995349462433e89 < b_2

    1. Initial program 45.0

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

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

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

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