Average Error: 34.4 → 9.6
Time: 4.9s
Precision: 64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.2077125772538958 \cdot 10^{29}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.5917437502612807 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 2.6627070202833933 \cdot 10^{70}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 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 \le -1.2077125772538958 \cdot 10^{29}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.5917437502612807 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\

\mathbf{elif}\;b_2 \le 2.6627070202833933 \cdot 10^{70}:\\
\;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\

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

\end{array}
double code(double a, double b_2, double c) {
	return ((double) (((double) (((double) -(b_2)) - ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))))) / a));
}
double code(double a, double b_2, double c) {
	double VAR;
	if ((b_2 <= -1.2077125772538958e+29)) {
		VAR = ((double) (-0.5 * ((double) (c / b_2))));
	} else {
		double VAR_1;
		if ((b_2 <= -1.5917437502612807e-308)) {
			VAR_1 = ((double) (((double) (((double) (0.0 + ((double) (a * c)))) / ((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))) - b_2)))) / a));
		} else {
			double VAR_2;
			if ((b_2 <= 2.6627070202833933e+70)) {
				VAR_2 = ((double) (((double) (((double) -(b_2)) - ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))))) * ((double) (1.0 / a))));
			} else {
				VAR_2 = ((double) (((double) (0.5 * ((double) (c / b_2)))) - ((double) (2.0 * ((double) (b_2 / a))))));
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 < -1.2077125772538958e+29

    1. Initial program 56.6

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

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

    if -1.2077125772538958e+29 < b_2 < -1.5917437502612807e-308

    1. Initial program 28.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-exp-log31.1

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}\]
    4. Using strategy rm
    5. Applied flip--31.1

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)} \cdot e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{\left(-b_2\right) + e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}}{a}\]
    6. Simplified20.7

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + e^{\log \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}\]
    7. Simplified18.1

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

    if -1.5917437502612807e-308 < b_2 < 2.6627070202833933e+70

    1. Initial program 10.6

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

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

    if 2.6627070202833933e+70 < b_2

    1. Initial program 40.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.2077125772538958 \cdot 10^{29}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.5917437502612807 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 2.6627070202833933 \cdot 10^{70}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020120 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))