Average Error: 34.3 → 7.0
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 \leq -7.356693308942923 \cdot 10^{+89}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -3.205290969087756 \cdot 10^{-292}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 1.695059459271918 \cdot 10^{+136}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -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 \leq -7.356693308942923 \cdot 10^{+89}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq -3.205290969087756 \cdot 10^{-292}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\

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

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

\end{array}
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -7.356693308942923e+89)
   (* -0.5 (/ c b_2))
   (if (<= b_2 -3.205290969087756e-292)
     (/ 1.0 (/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) c))
     (if (<= b_2 1.695059459271918e+136)
       (/ 1.0 (/ a (- (- b_2) (sqrt (- (* b_2 b_2) (* c a))))))
       (/ (* b_2 -2.0) a)))))
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.356693308942923e+89)) {
		VAR = ((double) (-0.5 * (c / b_2)));
	} else {
		double VAR_1;
		if ((b_2 <= -3.205290969087756e-292)) {
			VAR_1 = (1.0 / (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)) / c));
		} else {
			double VAR_2;
			if ((b_2 <= 1.695059459271918e+136)) {
				VAR_2 = (1.0 / (a / ((double) (((double) -(b_2)) - ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a))))))))));
			} else {
				VAR_2 = (((double) (b_2 * -2.0)) / 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 < -7.35669330894292303e89

    1. Initial program 59.1

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

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

    if -7.35669330894292303e89 < b_2 < -3.2052909690877559e-292

    1. Initial program 33.1

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

      \[\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.3

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

      \[\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 clear-num17.5

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

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

    if -3.2052909690877559e-292 < b_2 < 1.69505945927191801e136

    1. Initial program 9.4

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

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

    if 1.69505945927191801e136 < b_2

    1. Initial program 57.7

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

      \[\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. Simplified62.9

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 2.9

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a}\]
    7. Simplified2.9

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -7.356693308942923 \cdot 10^{+89}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq -3.205290969087756 \cdot 10^{-292}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{c}}\\ \mathbf{elif}\;b_2 \leq 1.695059459271918 \cdot 10^{+136}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array}\]

Reproduce

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