Average Error: 33.7 → 6.8
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.6939938219367456 \cdot 10^{+122}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq -5.520617265234985 \cdot 10^{-215}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.7571448887910518 \cdot 10^{+76}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \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 \leq -1.6939938219367456 \cdot 10^{+122}:\\
\;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\

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

\mathbf{elif}\;b_2 \leq 2.7571448887910518 \cdot 10^{+76}:\\
\;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\

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

\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.6939938219367456e+122)) {
		VAR = (((double) (((double) (((double) (0.5 * ((double) (c * (a / b_2))))) - b_2)) - b_2)) / a);
	} else {
		double VAR_1;
		if ((b_2 <= -5.520617265234985e-215)) {
			VAR_1 = (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)) / a);
		} else {
			double VAR_2;
			if ((b_2 <= 2.7571448887910518e+76)) {
				VAR_2 = (((double) -(c)) / ((double) (b_2 + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))))));
			} else {
				VAR_2 = ((double) (-0.5 * (c / b_2)));
			}
			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 < -1.6939938219367456e122

    1. Initial program Error: 52.1 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 52.1 bits

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

      \[\leadsto \frac{\color{blue}{\left(0.5 \cdot \frac{a \cdot c}{b_2} - b_2\right)} - b_2}{a}\]
    4. SimplifiedError: 3.0 bits

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

    if -1.6939938219367456e122 < b_2 < -5.5206172652349851e-215

    1. Initial program Error: 7.7 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 7.7 bits

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

    if -5.5206172652349851e-215 < b_2 < 2.75714488879105182e76

    1. Initial program Error: 28.6 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 28.6 bits

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--Error: 28.7 bits

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. SimplifiedError: 16.1 bits

      \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(-c\right)}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
    6. SimplifiedError: 16.1 bits

      \[\leadsto \frac{\frac{a \cdot \left(-c\right)}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied distribute-rgt-neg-outError: 16.1 bits

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-negError: 16.1 bits

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-negError: 16.1 bits

      \[\leadsto \color{blue}{-\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}}\]
    11. SimplifiedError: 10.4 bits

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

    if 2.75714488879105182e76 < b_2

    1. Initial program Error: 57.9 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 57.9 bits

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplificationError: 6.8 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.6939938219367456 \cdot 10^{+122}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq -5.520617265234985 \cdot 10^{-215}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.7571448887910518 \cdot 10^{+76}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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