Average Error: 34.0 → 9.6
Time: 4.7s
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.0366436397824178 \cdot 10^{68}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -8.21218726880377109 \cdot 10^{-92}:\\ \;\;\;\;\frac{\frac{\left({b_2}^{2} - {b_2}^{2}\right) + a \cdot c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{elif}\;b_2 \le -4.05237835825691163 \cdot 10^{-102}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.34931179548294658 \cdot 10^{30}:\\ \;\;\;\;\frac{\left(-b_2\right) + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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.0366436397824178 \cdot 10^{68}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -8.21218726880377109 \cdot 10^{-92}:\\
\;\;\;\;\frac{\frac{\left({b_2}^{2} - {b_2}^{2}\right) + a \cdot c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\

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

\mathbf{elif}\;b_2 \le 5.34931179548294658 \cdot 10^{30}:\\
\;\;\;\;\frac{\left(-b_2\right) + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 ((-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a);
}
double code(double a, double b_2, double c) {
	double temp;
	if ((b_2 <= -1.0366436397824178e+68)) {
		temp = (-0.5 * (c / b_2));
	} else {
		double temp_1;
		if ((b_2 <= -8.212187268803771e-92)) {
			temp_1 = ((((pow(b_2, 2.0) - pow(b_2, 2.0)) + (a * c)) / (-b_2 + sqrt(((b_2 * b_2) - (a * c))))) / a);
		} else {
			double temp_2;
			if ((b_2 <= -4.052378358256912e-102)) {
				temp_2 = (-0.5 * (c / b_2));
			} else {
				double temp_3;
				if ((b_2 <= 5.349311795482947e+30)) {
					temp_3 = ((-b_2 + -sqrt(((b_2 * b_2) - (a * c)))) / a);
				} else {
					temp_3 = ((0.5 * (c / b_2)) - (2.0 * (b_2 / a)));
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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.0366436397824178e+68 or -8.212187268803771e-92 < b_2 < -4.052378358256912e-102

    1. Initial program 57.1

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

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

    if -1.0366436397824178e+68 < b_2 < -8.212187268803771e-92

    1. Initial program 42.4

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \sqrt[3]{-b_2}} - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    4. Applied fma-neg45.3

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}, \sqrt[3]{-b_2}, -\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    5. Using strategy rm
    6. Applied fma-udef44.7

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

      \[\leadsto \frac{\color{blue}{\left(-b_2\right)} + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\]
    8. Using strategy rm
    9. Applied flip-+42.4

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

      \[\leadsto \frac{\frac{\color{blue}{\left({b_2}^{2} - {b_2}^{2}\right) + a \cdot c}}{\left(-b_2\right) - \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    11. Simplified15.8

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

    if -4.052378358256912e-102 < b_2 < 5.349311795482947e+30

    1. Initial program 13.0

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \sqrt[3]{-b_2}} - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    4. Applied fma-neg13.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}, \sqrt[3]{-b_2}, -\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    5. Using strategy rm
    6. Applied fma-udef13.1

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \sqrt[3]{-b_2} + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    7. Simplified13.0

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

    if 5.349311795482947e+30 < b_2

    1. Initial program 35.5

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

      \[\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.0366436397824178 \cdot 10^{68}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -8.21218726880377109 \cdot 10^{-92}:\\ \;\;\;\;\frac{\frac{\left({b_2}^{2} - {b_2}^{2}\right) + a \cdot c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{elif}\;b_2 \le -4.05237835825691163 \cdot 10^{-102}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.34931179548294658 \cdot 10^{30}:\\ \;\;\;\;\frac{\left(-b_2\right) + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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