quadratic formula

Consider the equation

$a{x}^2 + b{x} + c = 0 ,$

which we wish to solve for $x$. Assume that $a$, $b$, and $c$ are real numbers and that we wish $x$ to be a complex number. Assume that the equation is nontrivial in that $a \ne 0$, $c \ne 0$, or $b \ne 0$ (in which case $b \gt 0$ or $b \lt 0$). Then we expect two solutions, although they might happen to be the same, or one or both of them might be infinite (and so not exist as a complex number). I'll call these two solutions $x_+$ and $x_-$; which is which is somewhat arbitrary, but all of the formulas below are consistent about this.

If $a \ne 0$, then we may use the usual quadratic formula:

$\begin {gathered}
\displaystyle x_+ = \frac{-b + \sqrt{b^2 - 4a{c}}}{2a} ;\\
\displaystyle x_- = \frac{-b - \sqrt{b^2 - 4a{c}}}{2a} .\\
\end {gathered}$

If $c \ne 0$, then we may rationalize the numerator:

$\begin {gathered}
\displaystyle x_+ = \frac{2c}{-b - \sqrt{b^2 - 4a{c}}} ;\\
\displaystyle x_- = \frac{2c}{-b + \sqrt{b^2 - 4a{c}}} .\\
\end {gathered}$

If $b \gt 0$, then we may mix the formulas:

$\begin {gathered}
\displaystyle x_+ = \frac{2c}{-b - \sqrt{b^2 - 4a{c}}} ;\\
\displaystyle x_- = \frac{-b - \sqrt{b^2 - 4a{c}}}{2a} .\\
\end {gathered}$

If $b \lt 0$, then we may mix the formulas the other way:

$\begin {gathered}
\displaystyle x_+ = \frac{-b + \sqrt{b^2 - 4a{c}}}{2a} ;\\
\displaystyle x_- = \frac{2c}{-b + \sqrt{b^2 - 4a{c}}} .\\
\end {gathered}$

If more than one of the coefficients is nonzero, then you'll tend to minimize the risk of rounding errors (when using decimal approximations of the square roots) if you use the formula applicable to the coefficient that is the *most* nonzero (basically, the one with the largest absolute value, although the actual rule to pick the very best formula is more subtle).

Each of these formulas can sometimes give division by $0$, but if you're using it when you're supposed to, then that can only happen when the corresponding solution is infinite, so that's perfectly appropriate. But if you use a formula when it's inapplicable, then you'll get $0/0$ even if the solution is finite, and that's bad.

See quadratic formula for more advanced discussion.

Revised on November 1, 2017 18:15:23
by Toby Bartels
(64.89.52.16)