Quadratic formula
Template:Short description Template:Confused
In elementary algebra, the quadratic formula is a closed-form expression describing the solutions of a quadratic equation. Other ways of solving quadratic equations, such as completing the square, yield the same solutions.
Given a general quadratic equation of the form Template:Tmath, with Template:Tmath representing an unknown, and coefficients Template:Tmath, Template:Tmath, and Template:Tmath representing known real or complex numbers with Template:Tmath, the values of Template:Tmath satisfying the equation, called the roots or zeros, can be found using the quadratic formula,
<math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}, </math>
where the plus–minus symbol "Template:Tmath" indicates that the equation has two roots.<ref>Template:Citation</ref> Written separately, these are:
<math display=block> x_1 = \frac{-b + \sqrt {b^2 - 4ac}}{2a}, \qquad x_2 = \frac{-b - \sqrt {b^2 - 4ac}}{2a}. </math>
The quantity Template:Tmath is known as the discriminant of the quadratic equation.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> If the coefficients Template:Tmath, Template:Tmath, and Template:Tmath are real numbers then when Template:Tmath, the equation has two distinct real roots; when Template:Tmath, the equation has one repeated real root; and when Template:Tmath, the equation has no real roots but has two distinct complex roots, which are complex conjugates of each other.
Geometrically, the roots represent the Template:Tmath values at which the graph of the quadratic function Template:Tmath, a parabola, crosses the Template:Tmath-axis: the graph's Template:Tmath-intercepts.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The quadratic formula can also be used to identify the parabola's axis of symmetry.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>
Derivation by completing the squareEdit
The standard way to derive the quadratic formula is to apply the method of completing the square to the generic quadratic equation Template:Tmath.<ref>Template:Citation</ref><ref>Li, Xuhui. An Investigation of Secondary School Algebra Teachers' Mathematical Knowledge for Teaching Algebraic Equation Solving, p. 56 (ProQuest, 2007): "The quadratic formula is the most general method for solving quadratic equations and is derived from another general method: completing the square."</ref><ref>Rockswold, Gary. College algebra and trigonometry and precalculus, p. 178 (Addison Wesley, 2002).</ref><ref>Beckenbach, Edwin et al. Modern college algebra and trigonometry, p. 81 (Wadsworth Pub. Co., 1986).</ref> The idea is to manipulate the equation into the form Template:Tmath for some expressions Template:Tmath and Template:Tmath written in terms of the coefficients; take the square root of both sides; and then isolate Template:Tmath.
We start by dividing the equation by the quadratic coefficient Template:Tmath, which is allowed because Template:Tmath is non-zero. Afterwards, we subtract the constant term Template:Tmath to isolate it on the right-hand side:
<math display=block>\begin{align} ax^{2\vphantom|} + bx + c &= 0 \\[3mu] x^2 + \frac{b}{a} x + \frac{c}{a} &= 0 \\[3mu] x^2 + \frac{b}{a} x &= -\frac{c}{a}. \end{align}</math>
The left-hand side is now of the form Template:Tmath, and we can "complete the square" by adding a constant Template:Tmath to obtain a squared binomial Template:TmathTemplate:WbrTemplate:Tmath. In this example we add Template:Tmath to both sides so that the left-hand side can be factored (see the figure):
<math display=block>\begin{align} x^2 + 2\left(\frac{b}{2a}\right)x + \left(\frac{b}{2a}\right)^2 &= -\frac{c}{a}+\left( \frac{b}{2a} \right)^2 \\[5mu] \left(x + \frac{b}{2a}\right)^2 &= \frac{b^2 - 4ac}{4a^2} . \end{align}</math>
Because the left-hand side is now a perfect square, we can easily take the square root of both sides:
<math display=block> x + \frac{b}{2a} = \pm\frac{\sqrt{b^2 - 4ac}}{2a}. </math>
Finally, subtracting Template:Tmath from both sides to isolate Template:Tmath produces the quadratic formula:
<math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} . </math>
Equivalent formulationsEdit
The quadratic formula can equivalently be written using various alternative expressions, for instance
<math display=block> x = -\frac{b}{2a} \pm \sqrt{\left(\frac{b}{2a}\right)^2-\frac{c}{a}}, </math>
which can be derived by first dividing a quadratic equation by Template:Tmath, resulting in Template:Tmath, then substituting the new coefficients into the standard quadratic formula. Because this variant allows re-use of the intermediately calculated quantity Template:Tmath, it can slightly reduce the arithmetic involved.
Square root in the denominator Edit
A lesser known quadratic formula, first mentioned by Giulio Fagnano,<ref>Specifically, Fagnano began with the equation Template:Tmath and found the solutions to be <math display=block>x = \frac{2 bb}{a \mp a \sqrt{1 - \dfrac{4bb}{aa}}}.</math> (In the 18th century, the square Template:Tmath was conventionally written as Template:Nobr Template:Pb Template:Citation</ref> describes the same roots via an equation with the square root in the denominator (assuming Template:Tmath):
<math display=block> x= \frac{2c}{-b \mp \sqrt {b^2 - 4ac}}. </math>
Here the minus–plus symbol "Template:Tmath" indicates that the two roots of the quadratic equation, in the same order as the standard quadratic formula, are
<math display=block> x_1 = \frac{2c}{-b - \sqrt {b^2 - 4ac}}, \qquad x_2 = \frac{2c}{-b + \sqrt {b^2 - 4ac}}. </math>
This variant has been jokingly called the "citardauq" formula ("quadratic" spelled backwards).<ref>Template:Citation</ref>
When Template:Tmath has the opposite sign as either Template:Tmath or Template:Tmath, subtraction can cause catastrophic cancellation, resulting in poor accuracy in numerical calculations; choosing between the version of the quadratic formula with the square root in the numerator or denominator depending on the sign of Template:Tmath can avoid this problem. See Template:Slink below.
This version of the quadratic formula is used in Muller's method for finding the roots of general functions. It can be derived from the standard formula from the identity Template:Tmath, one of Vieta's formulas. Alternately, it can be derived by dividing each side of the equation Template:Tmath by Template:Tmath to get Template:Tmath, applying the standard formula to find the two roots Template:Tmath, and then taking the reciprocal to find the roots Template:Tmath of the original equation.
Template:Anchor Other derivationsEdit
Any generic method or algorithm for solving quadratic equations can be applied to an equation with symbolic coefficients and used to derive some closed-form expression equivalent to the quadratic formula. Alternative methods are sometimes simpler than completing the square, and may offer interesting insight into other areas of mathematics.
Completing the square by Śrīdhara's methodEdit
Instead of dividing by Template:Tmath to isolate Template:Tmath, it can be slightly simpler to multiply by Template:Tmath instead to produce Template:Tmath, which allows us to complete the square without need for fractions. Then the steps of the derivation are:<ref name="Hoehn1975">Template:Citation</ref>
- Multiply each side by Template:Tmath.
- Add Template:Tmath to both sides to complete the square.
- Take the square root of both sides.
- Isolate Template:Tmath.
Applying this method to a generic quadratic equation with symbolic coefficients yields the quadratic formula:
<math display=block>\begin{align} ax^2 + bx + c &= 0 \\[3mu] 4 a^2 x^2 + 4abx + 4ac &= 0 \\[3mu] 4 a^2 x^2 + 4abx + b^2 &= b^2 - 4ac \\[3mu] (2ax + b)^2 &= b^2 - 4ac \\[3mu] 2ax + b &= \pm \sqrt{b^2 - 4ac} \\[5mu] x &= \dfrac{-b\pm\sqrt{b^2 - 4ac }}{2a}. \vphantom\bigg) \end{align}</math>
This method for completing the square is ancient and was known to the 8th–9th century Indian mathematician Śrīdhara.<ref>Starting from a quadratic equation of the form Template:Tmath, Śrīdhara's method, as quoted by Bhāskara II (c. 1150): "Multiply both sides of the equation by a number equal to four times the [coefficient of the] square, and add to them a number equal to the square of the original [coefficient of the] unknown quantity. [Then extract the root.]". Template:Pb Template:Harvnb</ref> Compared with the modern standard method for completing the square, this alternate method avoids fractions until the last step and hence does not require a rearrangement after step 3 to obtain a common denominator in the right side.<ref name=Hoehn1975/>
By substitutionEdit
Another derivation uses a change of variables to eliminate the linear term. Then the equation takes the form Template:Tmath in terms of a new variable Template:Tmath and some constant expression Template:Tmath, whose roots are then Template:Tmath.
By substituting Template:Tmath into Template:Tmath, expanding the products and combining like terms, and then solving for Template:Tmath, we have:
<math display=block>\begin{align} a\left(u-\frac{b}{2a}\right)^2 + b\left(u-\frac{b}{2a}\right) + c &=0 \\[5mu] a\left(u^2-\frac{b}{a}u+\frac{b^2}{4a^2}\right) + b\left(u-\frac{b}{2a}\right) + c &= 0 \\[5mu] au^2 - bu + \frac{b^2}{4a} + bu - \frac{b^2}{2a}+c &= 0 \\[5mu] au^2 + \frac{4ac - b^2}{4a} &= 0 \\[5mu] u^2 &= \frac{b^2 - 4ac}{4a^2}. \end{align}</math>
Finally, after taking a square root of both sides and substituting the resulting expression for Template:Tmath back into Template:Tmath the familiar quadratic formula emerges:
<math display=block> x = \frac{-b\pm \sqrt{b^2 - 4ac}}{2a}. </math>
By using algebraic identitiesEdit
The following method was used by many historical mathematicians:<ref>Template:Citation</ref>
Let the roots of the quadratic equation Template:Tmath be Template:Tmath and Template:Tmath. The derivation starts from an identity for the square of a difference (valid for any two complex numbers), of which we can take the square root on both sides:
<math display=block>\begin{align} (\alpha - \beta)^2 &= (\alpha + \beta)^2 - 4 \alpha\beta \\[3mu] \alpha - \beta &= \pm\sqrt{(\alpha + \beta)^2 - 4 \alpha\beta} . \end{align}</math>
Since the coefficient Template:Tmath, we can divide the quadratic equation by Template:Tmath to obtain a monic polynomial with the same roots. Namely,
<math display=block> x^2 + \frac{b}{a}x + \frac{c}{a} = (x - \alpha)(x - \beta) = x^2 - (\alpha + \beta)x + \alpha\beta . </math>
This implies that the sum Template:Tmath and the product Template:Tmath. Thus the identity can be rewritten:
<math display=block> \alpha - \beta = \pm\sqrt{\left(-\frac{b}{a}\right)^2-4\frac{c}{a}} = \pm\frac{\sqrt{b^2 - 4ac}}{a} . </math>
Therefore,
<math display=block>\begin{align} \alpha &= \tfrac12(\alpha + \beta) + \tfrac12(\alpha - \beta)
= -\frac{b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a}, \\[10mu]
\beta &= \tfrac12(\alpha + \beta) - \tfrac12(\alpha - \beta)
= -\frac{b}{2a} \mp \frac{\sqrt{b^2 - 4ac}}{2a}.
\end{align}</math>
The two possibilities for each of Template:Tmath and Template:Tmath are the same two roots in opposite order, so we can combine them into the standard quadratic equation: <math display=block> x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} .</math>
By Lagrange resolventsEdit
Template:Details An alternative way of deriving the quadratic formula is via the method of Lagrange resolvents,<ref name=Clark>Clark, A. (1984). Elements of abstract algebra. Courier Corporation. p. 146.</ref> which is an early part of Galois theory.<ref name="efei">Template:Citation</ref> This method can be generalized to give the roots of cubic polynomials and quartic polynomials, and leads to Galois theory, which allows one to understand the solution of algebraic equations of any degree in terms of the symmetry group of their roots, the Galois group.
This approach focuses on the roots themselves rather than algebraically rearranging the original equation. Given a monic quadratic polynomial Template:Tmath assume that Template:Tmath and Template:Tmath are the two roots. So the polynomial factors as
<math display=block>\begin{align} x^2+px+q &= (x-\alpha)(x-\beta) \\[3mu]
&= x^2-(\alpha+\beta)x+\alpha\beta
\end{align}</math>
which implies Template:Tmath and Template:Tmath.
Since multiplication and addition are both commutative, exchanging the roots Template:Tmath and Template:Tmath will not change the coefficients Template:Tmath and Template:Tmath: one can say that Template:Tmath and Template:Tmath are symmetric polynomials in Template:Tmath and Template:Tmath. Specifically, they are the elementary symmetric polynomials – any symmetric polynomial in Template:Tmath and Template:Tmath can be expressed in terms of Template:Tmath and Template:Tmath instead.
The Galois theory approach to analyzing and solving polynomials is to ask whether, given coefficients of a polynomial each of which is a symmetric function in the roots, one can "break" the symmetry and thereby recover the roots. Using this approach, solving a polynomial of degree Template:Tmath is related to the ways of rearranging ("permuting") Template:Tmath terms, called the symmetric group on Template:Tmath letters and denoted Template:Tmath. For the quadratic polynomial, the only ways to rearrange two roots are to either leave them be or to transpose them, so solving a quadratic polynomial is simple.
To find the roots Template:Tmath and Template:Tmath, consider their sum and difference:
<math display=block> r_1 = \alpha + \beta, \quad r_2 = \alpha - \beta . </math>
These are called the Lagrange resolvents of the polynomial, from which the roots can be recovered as
<math display=block> \alpha = \tfrac12 (r_1 + r_2), \quad \beta = \tfrac12(r_1 - r_2). </math>
Because Template:Tmath is a symmetric function in Template:Tmath and Template:Tmath, it can be expressed in terms of Template:Tmath and Template:Tmath specifically Template:Tmath as described above. However, Template:Tmath is not symmetric, since exchanging Template:Tmath and Template:Tmath yields the additive inverse Template:Tmath. So Template:Tmath cannot be expressed in terms of the symmetric polynomials. However, its square Template:Tmath is symmetric in the roots, expressible in terms of Template:Tmath and Template:Tmath. Specifically Template:TmathTemplate:WbrTemplate:TmathTemplate:WbrTemplate:Tmath, which implies Template:Tmath. Taking the positive root "breaks" the symmetry, resulting in
<math display=block> r_1 = -p, \qquad r_2 = {\textstyle \sqrt{p^2 - 4q}} </math>
from which the roots Template:Tmath and Template:Tmath are recovered as
<math display=block> x = \tfrac12(r_1 \pm r_2) = \tfrac{1}{2} \bigl({-p} \pm {\textstyle \sqrt{p^2 - 4q}}\,\bigr) </math>
which is the quadratic formula for a monic polynomial.
Substituting Template:Tmath, Template:Tmath yields the usual expression for an arbitrary quadratic polynomial. The resolvents can be recognized as
<math display=block> \tfrac12 r_1 = -\tfrac12p = -\frac{b}{2a}, \qquad r_2^2 = p_2 - 4q = \frac{b^2 - 4ac}{a^2}, </math>
respectively the vertex and the discriminant of the monic polynomial.
A similar but more complicated method works for cubic equations, which have three resolvents and a quadratic equation (the "resolving polynomial") relating Template:Tmath and Template:Tmath, which one can solve by the quadratic equation, and similarly for a quartic equation (degree 4), whose resolving polynomial is a cubic, which can in turn be solved.<ref name=Clark/> The same method for a quintic equation yields a polynomial of degree 24, which does not simplify the problem, and, in fact, solutions to quintic equations in general cannot be expressed using only roots.
Numerical calculationEdit
The quadratic formula is exactly correct when performed using the idealized arithmetic of real numbers, but when approximate arithmetic is used instead, for example pen-and-paper arithmetic carried out to a fixed number of decimal places or the floating-point binary arithmetic available on computers, the limitations of the number representation can lead to substantially inaccurate results unless great care is taken in the implementation. Specific difficulties include catastrophic cancellation in computing the sum Template:Tmath if Template:Tmath; catastrophic calculation in computing the discriminant Template:Tmath itself in cases where Template:Tmath; degeneration of the formula when Template:Tmath, Template:Tmath, or Template:Tmath is represented as zero or infinite; and possible overflow or underflow when multiplying or dividing extremely large or small numbers, even in cases where the roots can be accurately represented.<ref>Template:Citation</ref><ref name=goualard>Template:Cite tech report</ref>
Catastrophic cancellation occurs when two numbers which are approximately equal are subtracted. While each of the numbers may independently be representable to a certain number of digits of precision, the identical leading digits of each number cancel, resulting in a difference of lower relative precision. When Template:Tmath, evaluation of Template:Tmath causes catastrophic cancellation, as does the evaluation of Template:Tmath when Template:Tmath. When using the standard quadratic formula, calculating one of the two roots always involves addition, which preserves the working precision of the intermediate calculations, while calculating the other root involves subtraction, which compromises it. Therefore, naïvely following the standard quadratic formula often yields one result with less relative precision than expected. Unfortunately, introductory algebra textbooks typically do not address this problem, even though it causes students to obtain inaccurate results in other school subjects such as introductory chemistry.<ref>Template:Citation</ref>
For example, if trying to solve the equation Template:Tmath using a pocket calculator, the result of the quadratic formula Template:Tmath might be approximately calculated as:<ref> This example comes from: Template:Pb Template:Citation</ref>
<math display=block>\begin{alignat}{3} x_1 &= 817 + 816.998\,776\,0 &&= 1.633\,998\,776 \times 10^3, \\ x_2 &= 817 - 816.998\,776\,0 &&= 1.224 \times 10^{-3}. \end{alignat}</math>
Even though the calculator used ten decimal digits of precision for each step, calculating the difference between two approximately equal numbers has yielded a result for Template:Tmath with only four correct digits.
One way to recover an accurate result is to use the identity Template:Tmath. In this example Template:Tmath can be calculated as Template:TmathTemplate:WbrTemplate:Tmath, which is correct to the full ten digits. Another more or less equivalent approach is to use the version of the quadratic formula with the square root in the denominator to calculate one of the roots (see Template:Slink above).
Practical computer implementations of the solution of quadratic equations commonly choose which formula to use for each root depending on the sign of Template:Tmath.<ref>Template:Citation</ref>
These methods do not prevent possible overflow or underflow of the floating-point exponent in computing Template:Tmath or Template:Tmath, which can lead to numerically representable roots not being computed accurately. A more robust but computationally expensive strategy is to start with the substitution Template:Tmath, turning the quadratic equation into
<math display=block> u^2 - 2 \frac{|b|}{2\sqrt{|a|}\sqrt{|c|}}u + \sgn(c) = 0, </math>
where Template:Tmath is the sign function. Letting Template:Tmath, this equation has the form Template:Tmath, for which one solution is Template:Tmath and the other solution is Template:Tmath. The roots of the original equation are then Template:Tmath and Template:Tmath.<ref>Template:Citation</ref><ref>Template:Citation</ref>
With additional complication the expense and extra rounding of the square roots can be avoided by approximating them as powers of two, while still avoiding exponent overflow for representable roots.Template:R
Historical developmentEdit
The earliest methods for solving quadratic equations were geometric. Babylonian cuneiform tablets contain problems reducible to solving quadratic equations.Template:Sfn The Egyptian Berlin Papyrus, dating back to the Middle Kingdom (2050 BC to 1650 BC), contains the solution to a two-term quadratic equation.<ref>Template:Citation</ref>
The Greek mathematician Euclid (circa 300 BC) used geometric methods to solve quadratic equations in Book 2 of his Elements, an influential mathematical treatiseTemplate:Sfn Rules for quadratic equations appear in the Chinese The Nine Chapters on the Mathematical Art circa 200 BC.<ref name=Aitken>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>Template:Sfn In his work Arithmetica, the Greek mathematician Diophantus (circa 250 AD) solved quadratic equations with a method more recognizably algebraic than the geometric algebra of Euclid.Template:Sfn His solution gives only one root, even when both roots are positive.Template:Sfn
The Indian mathematician Brahmagupta included a generic method for finding one root of a quadratic equation in his treatise Brāhmasphuṭasiddhānta (circa 628 AD), written out in words in the style of that time.<ref name=Bradley>Bradley, Michael. The Birth of Mathematics: Ancient Times to 1300, p. 86 (Infobase Publishing 2006).</ref><ref>Mackenzie, Dana. The Universe in Zero Words: The Story of Mathematics as Told through Equations, p. 61 (Princeton University Press, 2012).</ref> His solution of the quadratic equation Template:Tmath was as follows: "To the absolute number multiplied by four times the [coefficient of the] square, add the square of the [coefficient of the] middle term; the square root of the same, less the [coefficient of the] middle term, being divided by twice the [coefficient of the] square is the value."<ref name=Stillwell2004>Template:Citation</ref> In modern notation, this can be written Template:Tmath. The Indian mathematician Śrīdhara (8th–9th century) came up with a similar algorithm for solving quadratic equations in a now-lost work on algebra quoted by Bhāskara II.<ref>Template:MacTutor</ref> The modern quadratic formula is sometimes called Sridharacharya's formula in India and Bhaskara's formula in Brazil.<ref>Template:Cite thesis Template:Pb Template:Cite thesis Template:Pb Template:Cite magazine</ref>
The 9th-century Persian mathematician Muḥammad ibn Mūsā al-Khwārizmī solved quadratic equations algebraically.Template:Sfn The quadratic formula covering all cases was first obtained by Simon Stevin in 1594.<ref>Template:Citation</ref> In 1637 René Descartes published La Géométrie containing special cases of the quadratic formula in the form we know today.<ref>Template:Citation</ref>
Geometric significanceEdit
In terms of coordinate geometry, an axis-aligned parabola is a curve whose Template:Tmath-coordinates are the graph of a second-degree polynomial, of the form Template:Tmath, where Template:Tmath, Template:Tmath, and Template:Tmath are real-valued constant coefficients with Template:Tmath.
Geometrically, the quadratic formula defines the points Template:Tmath on the graph, where the parabola crosses the Template:Tmath-axis. Furthermore, it can be separated into two terms,
<math display=block> x = \frac{-b\pm\sqrt{b^2 - 4ac }}{2a} = -\frac{b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a}. </math>
The first term describes the axis of symmetry, the line Template:Tmath. The second term, Template:Tmath, gives the distance the roots are away from the axis of symmetry.
If the parabola's vertex is on the Template:Tmath-axis, then the corresponding equation has a single repeated root on the line of symmetry, and this distance term is zero; algebraically, the discriminant Template:Tmath.
If the discriminant is positive, then the vertex is not on the Template:Tmath-axis but the parabola opens in the direction of the Template:Tmath-axis, crossing it twice, so the corresponding equation has two real roots. If the discriminant is negative, then the parabola opens in the opposite direction, never crossing the Template:Tmath-axis, and the equation has no real roots; in this case the two complex-valued roots will be complex conjugates whose real part is the Template:Tmath value of the axis of symmetry.
Dimensional analysisEdit
If the constants Template:Tmath, Template:Tmath, and/or Template:Tmath are not unitless then the quantities Template:Tmath and Template:Tmath must have the same units, because the terms Template:Tmath and Template:Tmath agree on their units. By the same logic, the coefficient Template:Tmath must have the same units as Template:Tmath, irrespective of the units of Template:Tmath. This can be a powerful tool for verifying that a quadratic expression of physical quantities has been set up correctly.