Average Error: 34.2 → 8.7
Time: 5.2s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.35463732932135993 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.9146441501386442 \cdot 10^{-213}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.1588673707323962 \cdot 10^{152}:\\ \;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(2 \cdot \frac{a \cdot c}{b} - 2 \cdot b\right)}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.35463732932135993 \cdot 10^{154}:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\

\mathbf{elif}\;b \le 1.9146441501386442 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\

\mathbf{elif}\;b \le 1.1588673707323962 \cdot 10^{152}:\\
\;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\

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

\end{array}
double code(double a, double b, double c) {
	return ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a));
}
double code(double a, double b, double c) {
	double VAR;
	if ((b <= -1.35463732932136e+154)) {
		VAR = (((2.0 * ((a * c) / b)) - (2.0 * b)) / (2.0 * a));
	} else {
		double VAR_1;
		if ((b <= 1.9146441501386442e-213)) {
			VAR_1 = ((-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a));
		} else {
			double VAR_2;
			if ((b <= 1.1588673707323962e+152)) {
				VAR_2 = (1.0 / ((0.5 / c) * (-b - sqrt(((b * b) - ((4.0 * a) * c))))));
			} else {
				VAR_2 = (1.0 / (((2.0 * a) / (4.0 * (a * c))) * ((2.0 * ((a * c) / b)) - (2.0 * b))));
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus a

Bits error versus b

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 < -1.35463732932136e+154

    1. Initial program 64.0

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

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

    if -1.35463732932136e+154 < b < 1.9146441501386442e-213

    1. Initial program 9.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-*l*9.4

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

    if 1.9146441501386442e-213 < b < 1.1588673707323962e+152

    1. Initial program 38.4

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    4. Simplified16.1

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num16.3

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

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    8. Taylor expanded around 0 6.9

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

    if 1.1588673707323962e+152 < b

    1. Initial program 63.7

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    4. Simplified38.1

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num38.1

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}\]
    7. Simplified38.0

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    8. Taylor expanded around inf 8.2

      \[\leadsto \frac{1}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \color{blue}{\left(2 \cdot \frac{a \cdot c}{b} - 2 \cdot b\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.35463732932135993 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.9146441501386442 \cdot 10^{-213}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.1588673707323962 \cdot 10^{152}:\\ \;\;\;\;\frac{1}{\frac{0.5}{c} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(2 \cdot \frac{a \cdot c}{b} - 2 \cdot b\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020103 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))