Average Error: 34.3 → 6.6
Time: 5.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.746806209943982 \cdot 10^{+150}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.4772792552103187 \cdot 10^{-257}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 7.36932297436956 \cdot 10^{+143}:\\ \;\;\;\;\left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{-1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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.746806209943982 \cdot 10^{+150}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 1.4772792552103187 \cdot 10^{-257}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\

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

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\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.746806209943982e+150)
   (* -0.5 (/ c b_2))
   (if (<= b_2 1.4772792552103187e-257)
     (/ 1.0 (/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) c))
     (if (<= b_2 7.36932297436956e+143)
       (* (+ b_2 (sqrt (- (* b_2 b_2) (* c a)))) (/ -1.0 a))
       (* -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.746806209943982e+150) {
		tmp = -0.5 * (c / b_2);
	} else if (b_2 <= 1.4772792552103187e-257) {
		tmp = 1.0 / ((sqrt((b_2 * b_2) - (c * a)) - b_2) / c);
	} else if (b_2 <= 7.36932297436956e+143) {
		tmp = (b_2 + sqrt((b_2 * b_2) - (c * a))) * (-1.0 / a);
	} else {
		tmp = -2.0 * (b_2 / a);
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -2.7468062099439819e150

    1. Initial program 63.6

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

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

    if -2.7468062099439819e150 < b_2 < 1.4772792552103187e-257

    1. Initial program 32.2

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

      \[\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}\]
    4. Simplified14.8

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied clear-num_binary6415.0

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}}\]
    8. Simplified8.6

      \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}\]

    if 1.4772792552103187e-257 < b_2 < 7.3693229743695601e143

    1. Initial program 8.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied div-inv_binary648.5

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

    if 7.3693229743695601e143 < b_2

    1. Initial program 60.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--_binary6464.0

      \[\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}\]
    4. Simplified62.8

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 2.7

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.746806209943982 \cdot 10^{+150}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.4772792552103187 \cdot 10^{-257}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 7.36932297436956 \cdot 10^{+143}:\\ \;\;\;\;\left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{-1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020299 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))