Average Error: 34.2 → 9.8
Time: 9.7s
Precision: binary64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := -a \cdot c\\ \mathbf{if}\;b_2 \leq -8.652110117963774 \cdot 10^{+151}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \mathbf{elif}\;b_2 \leq -2.650105651345541 \cdot 10^{-96}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \leq 2.0458807915557303 \cdot 10^{-221}:\\ \;\;\;\;\frac{\left(-b_2\right) + \mathsf{hypot}\left(b_2, \sqrt{t_0}\right)}{a}\\ \mathbf{elif}\;b_2 \leq 1.6819277248169715 \cdot 10^{-81}:\\ \;\;\;\;\left(\sqrt{\mathsf{fma}\left(b_2, b_2, t_0\right)} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := -a \cdot c\\
\mathbf{if}\;b_2 \leq -8.652110117963774 \cdot 10^{+151}:\\
\;\;\;\;\frac{-2 \cdot b_2}{a}\\

\mathbf{elif}\;b_2 \leq -2.650105651345541 \cdot 10^{-96}:\\
\;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

\mathbf{elif}\;b_2 \leq 2.0458807915557303 \cdot 10^{-221}:\\
\;\;\;\;\frac{\left(-b_2\right) + \mathsf{hypot}\left(b_2, \sqrt{t_0}\right)}{a}\\

\mathbf{elif}\;b_2 \leq 1.6819277248169715 \cdot 10^{-81}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(b_2, b_2, t_0\right)} - b_2\right) \cdot \frac{1}{a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\


\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
 (let* ((t_0 (- (* a c))))
   (if (<= b_2 -8.652110117963774e+151)
     (/ (* -2.0 b_2) a)
     (if (<= b_2 -2.650105651345541e-96)
       (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
       (if (<= b_2 2.0458807915557303e-221)
         (/ (+ (- b_2) (hypot b_2 (sqrt t_0))) a)
         (if (<= b_2 1.6819277248169715e-81)
           (* (- (sqrt (fma b_2 b_2 t_0)) b_2) (/ 1.0 a))
           (* -0.5 (/ c b_2))))))))
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 t_0 = -(a * c);
	double tmp;
	if (b_2 <= -8.652110117963774e+151) {
		tmp = (-2.0 * b_2) / a;
	} else if (b_2 <= -2.650105651345541e-96) {
		tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
	} else if (b_2 <= 2.0458807915557303e-221) {
		tmp = (-b_2 + hypot(b_2, sqrt(t_0))) / a;
	} else if (b_2 <= 1.6819277248169715e-81) {
		tmp = (sqrt(fma(b_2, b_2, t_0)) - b_2) * (1.0 / a);
	} else {
		tmp = -0.5 * (c / b_2);
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 5 regimes
  2. if b_2 < -8.65211011796377423e151

    1. Initial program 63.4

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]

    if -8.65211011796377423e151 < b_2 < -2.65010565134554118e-96

    1. Initial program 5.1

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

    if -2.65010565134554118e-96 < b_2 < 2.04588079155573025e-221

    1. Initial program 14.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied egg-rr13.4

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

    if 2.04588079155573025e-221 < b_2 < 1.6819277248169715e-81

    1. Initial program 22.3

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

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

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

    if 1.6819277248169715e-81 < b_2

    1. Initial program 52.6

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification9.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -8.652110117963774 \cdot 10^{+151}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \mathbf{elif}\;b_2 \leq -2.650105651345541 \cdot 10^{-96}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \leq 2.0458807915557303 \cdot 10^{-221}:\\ \;\;\;\;\frac{\left(-b_2\right) + \mathsf{hypot}\left(b_2, \sqrt{-a \cdot c}\right)}{a}\\ \mathbf{elif}\;b_2 \leq 1.6819277248169715 \cdot 10^{-81}:\\ \;\;\;\;\left(\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array} \]

Reproduce

herbie shell --seed 2022129 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))