Average Error: 34.3 → 6.8
Time: 5.0s
Precision: binary64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -3.8900654094429814 \cdot 10^{+133}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\ \mathbf{elif}\;b_2 \le -7.883473021605369 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.0729035470079235 \cdot 10^{+71}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}\\ \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 -3.8900654094429814 \cdot 10^{+133}:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\

\mathbf{elif}\;b_2 \le -7.883473021605369 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le 1.0729035470079235 \cdot 10^{+71}:\\
\;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}\\

\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 <= -3.8900654094429814e+133)) {
		VAR = ((double) (((double) (0.5 * ((double) (c / b_2)))) + ((double) (b_2 * ((double) (-2.0 / a))))));
	} else {
		double VAR_1;
		if ((b_2 <= -7.883473021605369e-300)) {
			VAR_1 = ((double) (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) / a)) - ((double) (b_2 / a))));
		} else {
			double VAR_2;
			if ((b_2 <= 1.0729035470079235e+71)) {
				VAR_2 = ((double) (((double) -(c)) / ((double) (b_2 + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a))))))))));
			} else {
				VAR_2 = ((double) (((double) -(c)) / ((double) (b_2 + ((double) (b_2 + ((double) (a * ((double) (-0.5 / ((double) (b_2 / c))))))))))));
			}
			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 < -3.89006540944298138e133

    1. Initial program 57.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.5

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    4. Simplified2.8

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

    if -3.89006540944298138e133 < b_2 < -7.8834730216053692e-300

    1. Initial program 9.3

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub9.3

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

    if -7.8834730216053692e-300 < b_2 < 1.07290354700792347e71

    1. Initial program 31.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--31.0

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

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

      \[\leadsto \frac{\frac{0 - a \cdot c}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied sub0-neg16.5

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-neg16.5

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-neg16.5

      \[\leadsto \color{blue}{-\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}}\]
    11. Simplified9.2

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

    if 1.07290354700792347e71 < b_2

    1. Initial program 57.3

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--57.3

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

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

      \[\leadsto \frac{\frac{0 - a \cdot c}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied sub0-neg30.1

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-neg30.1

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-neg30.1

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

      \[\leadsto -\color{blue}{1 \cdot \frac{c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    12. Taylor expanded around inf 7.0

      \[\leadsto -1 \cdot \frac{c}{b_2 + \color{blue}{\left(b_2 - 0.5 \cdot \frac{a \cdot c}{b_2}\right)}}\]
    13. Simplified3.2

      \[\leadsto -1 \cdot \frac{c}{b_2 + \color{blue}{\left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.8900654094429814 \cdot 10^{+133}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + b_2 \cdot \frac{-2}{a}\\ \mathbf{elif}\;b_2 \le -7.883473021605369 \cdot 10^{-300}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.0729035470079235 \cdot 10^{+71}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b_2 + \left(b_2 + a \cdot \frac{-0.5}{\frac{b_2}{c}}\right)}\\ \end{array}\]

Reproduce

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