Average Error: 33.8 → 6.8
Time: 4.9s
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 -7.1477916520959866 \cdot 10^{+134}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -8.989497529056973 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 9.31225597957106 \cdot 10^{+111}:\\ \;\;\;\;\left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{-1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot 0.5 + \frac{b_2}{a} \cdot -2\\ \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 -7.1477916520959866 \cdot 10^{+134}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq -8.989497529056973 \cdot 10^{-277}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\

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

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

\end{array}
double code(double a, double b_2, double c) {
	return (((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 <= -7.1477916520959866e+134)) {
		VAR = ((double) (-0.5 * (c / b_2)));
	} else {
		double VAR_1;
		if ((b_2 <= -8.989497529056973e-277)) {
			VAR_1 = (c / ((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)));
		} else {
			double VAR_2;
			if ((b_2 <= 9.31225597957106e+111)) {
				VAR_2 = ((double) (((double) (b_2 + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))))) * (-1.0 / a)));
			} else {
				VAR_2 = ((double) (((double) ((c / b_2) * 0.5)) + ((double) ((b_2 / a) * -2.0))));
			}
			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 < -7.1477916520959866e134

    1. Initial program 61.7

      \[\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}{-0.5 \cdot \frac{c}{b_2}}\]

    if -7.1477916520959866e134 < b_2 < -8.9894975290569731e-277

    1. Initial program 35.1

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

      \[\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. Simplified17.0

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

      \[\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 *-un-lft-identity17.0

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity17.0

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac17.0

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

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

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

    if -8.9894975290569731e-277 < b_2 < 9.31225597957105964e111

    1. Initial program 9.7

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

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

    if 9.31225597957105964e111 < b_2

    1. Initial program 48.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -7.1477916520959866 \cdot 10^{+134}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -8.989497529056973 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\\ \mathbf{elif}\;b_2 \leq 9.31225597957106 \cdot 10^{+111}:\\ \;\;\;\;\left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{-1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot 0.5 + \frac{b_2}{a} \cdot -2\\ \end{array}\]

Reproduce

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