Average Error: 34.3 → 6.9
Time: 6.3s
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 -5.9551520595513616 \cdot 10^{118}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -6.79526900931122647 \cdot 10^{-245}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\\ \mathbf{elif}\;b_2 \le 5.34931179548294658 \cdot 10^{30}:\\ \;\;\;\;\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \frac{1}{\frac{1}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_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 \le -5.9551520595513616 \cdot 10^{118}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

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

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

\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 <= -5.955152059551362e+118)) {
		temp = ((0.5 * (c / b_2)) - (2.0 * (b_2 / a)));
	} else {
		double temp_1;
		if ((b_2 <= -6.7952690093112265e-245)) {
			temp_1 = (1.0 / (a / (sqrt(((b_2 * b_2) - (a * c))) - b_2)));
		} else {
			double temp_2;
			if ((b_2 <= 5.349311795482947e+30)) {
				temp_2 = ((1.0 / (-b_2 - sqrt(((b_2 * b_2) - (a * c))))) * (1.0 / (1.0 / c)));
			} else {
				temp_2 = (-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 < -5.955152059551362e+118

    1. Initial program 52.1

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

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

    if -5.955152059551362e+118 < b_2 < -6.7952690093112265e-245

    1. Initial program 7.5

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

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

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

    if -6.7952690093112265e-245 < b_2 < 5.349311795482947e+30

    1. Initial program 26.2

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

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

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.5

      \[\leadsto \frac{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\color{blue}{1 \cdot a}}\]
    7. Applied associate-/r*16.5

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

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt39.6

      \[\leadsto \frac{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}\]
    11. Applied div-inv39.6

      \[\leadsto \frac{\frac{a}{\color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{c}}}}{\sqrt{a} \cdot \sqrt{a}}\]
    12. Applied add-sqr-sqrt39.5

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{c}}}{\sqrt{a} \cdot \sqrt{a}}\]
    13. Applied times-frac39.8

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

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

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

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

    if 5.349311795482947e+30 < b_2

    1. Initial program 56.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.9551520595513616 \cdot 10^{118}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -6.79526900931122647 \cdot 10^{-245}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\\ \mathbf{elif}\;b_2 \le 5.34931179548294658 \cdot 10^{30}:\\ \;\;\;\;\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \frac{1}{\frac{1}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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