Average Error: 34.6 → 10.4
Time: 4.6s
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.37866586320142018 \cdot 10^{-92}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.3130237661631722 \cdot 10^{-125}:\\ \;\;\;\;\frac{1 \cdot \mathsf{fma}\left(b_2, b_2, -\left(b_2 \cdot b_2 - a \cdot c\right)\right)}{a} \cdot \frac{1}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le -9.09785312290987894 \cdot 10^{-156}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.9701546350182474 \cdot 10^{129}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \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.37866586320142018 \cdot 10^{-92}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -6.3130237661631722 \cdot 10^{-125}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(b_2, b_2, -\left(b_2 \cdot b_2 - a \cdot c\right)\right)}{a} \cdot \frac{1}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\

\mathbf{elif}\;b_2 \le -9.09785312290987894 \cdot 10^{-156}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\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 ((-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a);
}
double code(double a, double b_2, double c) {
	double VAR;
	if ((b_2 <= -1.3786658632014202e-92)) {
		VAR = (-0.5 * (c / b_2));
	} else {
		double VAR_1;
		if ((b_2 <= -6.313023766163172e-125)) {
			VAR_1 = (((1.0 * fma(b_2, b_2, -((b_2 * b_2) - (a * c)))) / a) * (1.0 / (-b_2 + sqrt(((b_2 * b_2) - (a * c))))));
		} else {
			double VAR_2;
			if ((b_2 <= -9.097853122909879e-156)) {
				VAR_2 = (-0.5 * (c / b_2));
			} else {
				double VAR_3;
				if ((b_2 <= 3.9701546350182474e+129)) {
					VAR_3 = (1.0 / (a / (-b_2 - sqrt(((b_2 * b_2) - (a * c))))));
				} else {
					VAR_3 = ((0.5 * (c / b_2)) - (2.0 * (b_2 / a)));
				}
				VAR_2 = VAR_3;
			}
			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.3786658632014202e-92 or -6.313023766163172e-125 < b_2 < -9.097853122909879e-156

    1. Initial program 51.3

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

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

    if -1.3786658632014202e-92 < b_2 < -6.313023766163172e-125

    1. Initial program 26.2

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

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

      \[\leadsto \frac{1}{\frac{a}{\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}}}}}\]
    6. Applied associate-/r/26.3

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\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}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied add-cube-cbrt26.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{a}{\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}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    8. Applied times-frac26.3

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{a}{\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}}} \cdot \frac{\sqrt[3]{1}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified26.1

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

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

    if -9.097853122909879e-156 < b_2 < 3.9701546350182474e+129

    1. Initial program 10.9

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

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

    if 3.9701546350182474e+129 < b_2

    1. Initial program 54.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.37866586320142018 \cdot 10^{-92}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.3130237661631722 \cdot 10^{-125}:\\ \;\;\;\;\frac{1 \cdot \mathsf{fma}\left(b_2, b_2, -\left(b_2 \cdot b_2 - a \cdot c\right)\right)}{a} \cdot \frac{1}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le -9.09785312290987894 \cdot 10^{-156}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.9701546350182474 \cdot 10^{129}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020106 +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))