Average Error: 33.6 → 9.9
Time: 4.7s
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 -1.563718320049384 \cdot 10^{+132}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a} \cdot -2\\ \mathbf{elif}\;b_2 \leq 1.1872250410793767 \cdot 10^{-70}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \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 -1.563718320049384 \cdot 10^{+132}:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a} \cdot -2\\

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

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

\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 <= -1.563718320049384e+132)) {
		VAR = ((double) (((double) (0.5 * (c / b_2))) + ((double) ((b_2 / a) * -2.0))));
	} else {
		double VAR_1;
		if ((b_2 <= 1.1872250410793767e-70)) {
			VAR_1 = ((double) ((((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) / a) - (b_2 / a)));
		} else {
			VAR_1 = ((double) ((c / b_2) * -0.5));
		}
		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 3 regimes
  2. if b_2 < -1.56371832004938414e132

    1. Initial program 55.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified55.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub55.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}}\]
    5. Taylor expanded around -inf 3.0

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

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

    if -1.56371832004938414e132 < b_2 < 1.18722504107937671e-70

    1. Initial program 12.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified12.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-sub12.4

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

    if 1.18722504107937671e-70 < b_2

    1. Initial program 53.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified53.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 8.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.563718320049384 \cdot 10^{+132}:\\ \;\;\;\;0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a} \cdot -2\\ \mathbf{elif}\;b_2 \leq 1.1872250410793767 \cdot 10^{-70}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot -0.5\\ \end{array}\]

Reproduce

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