Average Error: 34.0 → 8.6
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 -5.134717094691006 \cdot 10^{+37}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := -c \cdot a\\ \mathbf{if}\;b_2 \leq 1.5302979495318542 \cdot 10^{-196}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{t_0}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 3.465292549325922 \cdot 10^{+78}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, t_0\right)}}{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 -5.134717094691006 \cdot 10^{+37}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \leq 3.465292549325922 \cdot 10^{+78}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, t_0\right)}}{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 -5.134717094691006e+37)
   (* -0.5 (/ c b_2))
   (let* ((t_0 (- (* c a))))
     (if (<= b_2 1.5302979495318542e-196)
       (/ c (- (hypot (sqrt t_0) b_2) b_2))
       (if (<= b_2 3.465292549325922e+78)
         (/ (- (- b_2) (sqrt (fma b_2 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 <= -5.134717094691006e+37) {
		tmp = -0.5 * (c / b_2);
	} else {
		double t_0 = -(c * a);
		double tmp_1;
		if (b_2 <= 1.5302979495318542e-196) {
			tmp_1 = c / (hypot(sqrt(t_0), b_2) - b_2);
		} else if (b_2 <= 3.465292549325922e+78) {
			tmp_1 = (-b_2 - sqrt(fma(b_2, 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 < -5.13471709469100557e37

    1. Initial program 57.3

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

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

    if -5.13471709469100557e37 < b_2 < 1.5302979495318542e-196

    1. Initial program 26.5

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

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

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

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

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

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

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

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

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

    if 1.5302979495318542e-196 < b_2 < 3.46529254932592214e78

    1. Initial program 7.7

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

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

    if 3.46529254932592214e78 < b_2

    1. Initial program 41.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -5.134717094691006 \cdot 10^{+37}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.5302979495318542 \cdot 10^{-196}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(\sqrt{-c \cdot a}, b_2\right) - b_2}\\ \mathbf{elif}\;b_2 \leq 3.465292549325922 \cdot 10^{+78}:\\ \;\;\;\;\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 2022104 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))