Average Error: 34.1 → 8.4
Time: 7.2s
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 -0.04248736169027556:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.8324699600337675 \cdot 10^{-264}:\\ \;\;\;\;\frac{1}{a \cdot \frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}\\ \mathbf{elif}\;b_2 \le 2.77441872967825971 \cdot 10^{150}:\\ \;\;\;\;\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 -0.04248736169027556:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -3.8324699600337675 \cdot 10^{-264}:\\
\;\;\;\;\frac{1}{a \cdot \frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}\\

\mathbf{elif}\;b_2 \le 2.77441872967825971 \cdot 10^{150}:\\
\;\;\;\;\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 <= -0.04248736169027556)) {
		VAR = (-0.5 * (c / b_2));
	} else {
		double VAR_1;
		if ((b_2 <= -3.8324699600337675e-264)) {
			VAR_1 = (1.0 / (a * (((sqrt(((b_2 * b_2) - (a * c))) - b_2) / a) / c)));
		} else {
			double VAR_2;
			if ((b_2 <= 2.7744187296782597e+150)) {
				VAR_2 = (1.0 / (a / (-b_2 - sqrt(((b_2 * b_2) - (a * c))))));
			} else {
				VAR_2 = ((0.5 * (c / b_2)) - (2.0 * (b_2 / 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 < -0.04248736169027556

    1. Initial program 56.0

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

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

    if -0.04248736169027556 < b_2 < -3.8324699600337675e-264

    1. Initial program 27.7

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

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

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

      \[\leadsto \frac{\frac{0 + 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.7

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}}}{a}\]
    9. Using strategy rm
    10. Applied associate-/l/14.6

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

    if -3.8324699600337675e-264 < b_2 < 2.7744187296782597e+150

    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.6

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

    if 2.7744187296782597e+150 < b_2

    1. Initial program 62.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -0.04248736169027556:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.8324699600337675 \cdot 10^{-264}:\\ \;\;\;\;\frac{1}{a \cdot \frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}{c}}\\ \mathbf{elif}\;b_2 \le 2.77441872967825971 \cdot 10^{150}:\\ \;\;\;\;\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 2020105 
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))