Average Error: 33.7 → 9.0
Time: 5.4s
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 -7.70031330541463201 \cdot 10^{138}:\\ \;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 8.0203295214211515 \cdot 10^{-175}:\\ \;\;\;\;1 \cdot \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \le 42194588.455395833:\\ \;\;\;\;1 \cdot \frac{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\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 -7.70031330541463201 \cdot 10^{138}:\\
\;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\

\mathbf{elif}\;b_2 \le 8.0203295214211515 \cdot 10^{-175}:\\
\;\;\;\;1 \cdot \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

\mathbf{elif}\;b_2 \le 42194588.455395833:\\
\;\;\;\;1 \cdot \frac{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)\\

\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 <= -7.700313305414632e+138)) {
		temp = (1.0 * ((0.5 * (c / b_2)) - (2.0 * (b_2 / a))));
	} else {
		double temp_1;
		if ((b_2 <= 8.020329521421151e-175)) {
			temp_1 = (1.0 * ((-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a));
		} else {
			double temp_2;
			if ((b_2 <= 42194588.45539583)) {
				temp_2 = (1.0 * (((0.0 + (a * c)) / (-b_2 - sqrt(((b_2 * b_2) - (a * c))))) / a));
			} else {
				temp_2 = (1.0 * (-0.5 * (c / b_2)));
			}
			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 < -7.700313305414632e+138

    1. Initial program 57.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity57.3

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    4. Applied *-un-lft-identity57.3

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

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

      \[\leadsto \color{blue}{1} \cdot \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    7. Taylor expanded around -inf 2.9

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

    if -7.700313305414632e+138 < b_2 < 8.020329521421151e-175

    1. Initial program 10.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity10.4

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    4. Applied *-un-lft-identity10.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{1 \cdot a}\]
    5. Applied times-frac10.4

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

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

    if 8.020329521421151e-175 < b_2 < 42194588.45539583

    1. Initial program 31.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity31.5

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    4. Applied *-un-lft-identity31.5

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{1 \cdot a}\]
    5. Applied times-frac31.5

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

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

      \[\leadsto 1 \cdot \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}\]
    9. Simplified17.1

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

    if 42194588.45539583 < b_2

    1. Initial program 55.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity55.9

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    4. Applied *-un-lft-identity55.9

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

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

      \[\leadsto \color{blue}{1} \cdot \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    7. Taylor expanded around inf 5.9

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.70031330541463201 \cdot 10^{138}:\\ \;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 8.0203295214211515 \cdot 10^{-175}:\\ \;\;\;\;1 \cdot \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \le 42194588.455395833:\\ \;\;\;\;1 \cdot \frac{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)\\ \end{array}\]

Reproduce

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