Average Error: 34.6 → 8.9
Time: 4.8s
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 -2.3941494279877027 \cdot 10^{+132}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.517728687625501 \cdot 10^{-233}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 7.210670058365327 \cdot 10^{+25}:\\ \;\;\;\;\frac{\frac{c \cdot \left(-a\right)}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{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 -2.3941494279877027 \cdot 10^{+132}:\\
\;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\

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

\mathbf{elif}\;b_2 \leq 7.210670058365327 \cdot 10^{+25}:\\
\;\;\;\;\frac{\frac{c \cdot \left(-a\right)}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{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 <= -2.3941494279877027e+132)) {
		VAR = (((double) (((double) (((double) (0.5 * ((double) (c * (a / b_2))))) - b_2)) - b_2)) / a);
	} else {
		double VAR_1;
		if ((b_2 <= 2.517728687625501e-233)) {
			VAR_1 = (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)) / a);
		} else {
			double VAR_2;
			if ((b_2 <= 7.210670058365327e+25)) {
				VAR_2 = ((((double) (c * ((double) -(a)))) / ((double) (b_2 + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a))))))))) / 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 < -2.3941494279877027e132

    1. Initial program 55.9

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

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

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

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

    if -2.3941494279877027e132 < b_2 < 2.51772868762550106e-233

    1. Initial program 9.9

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

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

    if 2.51772868762550106e-233 < b_2 < 7.2106700583653271e25

    1. Initial program 31.7

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

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

      \[\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. Simplified18.1

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

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

    if 7.2106700583653271e25 < b_2

    1. Initial program 56.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.3941494279877027 \cdot 10^{+132}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 2.517728687625501 \cdot 10^{-233}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 7.210670058365327 \cdot 10^{+25}:\\ \;\;\;\;\frac{\frac{c \cdot \left(-a\right)}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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