Quadratic equation

/div>
Jump to: navigation, search

In mathematics, a quadratic equation is a univariate polynomial equation of the second degree. A general quadratic equation can be written in the form

ax^2+bx+c=0,\,

where x represents a variable or an unknown, and a, b, and c are constants with a ≠ 0. (If a = 0, the equation is a linear equation.)

Note: Dividing the quadratic equation by a gives the simplified monic form x2 + px + q = 0, where p = b/a and q = c/a.

The constants a, b, and c are called respectively, the quadratic coefficient, the linear coefficient and the constant term or free term.[1] Quadratic equations can be solved by factoring, completing the square, using the quadratic formula, and graphing.

Plots of quadratic function y = ax2 + bx + c, varying each coefficient separately while the other coefficients are fixed (at values a = 1, b = 0, c = 0)

Contents

[ Solving the quadratic equation

For the quadratic function:
f (x) = x2x − 2 = (x + 1)(x − 2) of a real variable x, the x-coordinates of the points where the graph intersects the x-axis, x = −1 and x = 2, are the solutions of the quadratic equation: x2x − 2 = 0.

A quadratic equation with real or complex coefficients has two solutions, called roots. These two solutions may or may not be distinct, and they may or may not be real.

[ Factoring by inspection

For most students, factoring by inspection is the first method of solving quadratic equations to which they are exposed.[2]:202–207 If one is given a quadratic equation in monic form, x2 + bx + c = 0, one would seek to find two numbers that add up to b and whose product is c ("Viete's Rule"). The more general case where a ≠ 1 can require a considerable effort in trial and error guess-and-check, assuming that it can be factored at all by inspection.

Except for special cases such as where b = 0 or c = 0, factoring by inspection only works for quadratic equations that have rational roots. This means that the great majority of quadratic equations that arise in practical applications cannot be solved by factoring.[2]:207

[ Completing the square

Completing the square makes use of the algebraic identity:

x^2+2xh+h^2 = (x+h)^2.\,\!

It represents a well-defined algorithm that can be used to solve any quadratic equation.[2]:207 Starting with a quadratic equation in standard form, ax2 + bx + c = 0:

  1. Divide each side by a, the coefficient of x.
  2. Rearrange the equation so that the constant term c/a is on the right side.
  3. Add the square of one-half of b/a, the coefficient of x, to both sides. This "completes the square", converting the left side into a perfect square.
  4. Write the left side as a square, and simplify the right side, if necessary.
  5. Produce two linear equations by equating the square root of the left side with the positive and negative square roots of the right side.
  6. Solve the two linear equations.

We illustrate use of this algorithm by solving 2x2 + 4x − 4 = 0:

  1. x2 + 2x − 2 = 0
  2. x2 + 2x = 2
  3. x2 + 2x + 1 = 1 + 2
  4. (x + 1)2 = 3
  5. x + 1 = ±√
  6. x = −1 ± √

[ Derivation of the quadratic formula

Completing the square can be used to derive a general formula for solving quadratic equations, the quadratic formula.[3]

Dividing the quadratic equation

ax^2+bx+c=0 \,\!

by a (which is allowed because a is non-zero), gives:

x^2 + \frac{b}{a} x + \frac{c}{a}=0,\,\!

or

x^2 + \frac{b}{a} x= -\frac{c}{a}.

The quadratic equation is now in a form to which the method of completing the square can be applied. To "complete the square" is to add a constant to both sides of the equation such that the left hand side becomes a complete square:

x^2+\frac{b}{a}x+\left( \frac{1}{2}\frac{b}{a} \right)^2 =-\frac{c}{a}+\left( \frac{1}{2}\frac{b}{a} \right)^2,\!

which produces

\left(x+\frac{b}{2a}\right)^2=-\frac{c}{a}+\frac{b^2}{4a^2}.\,\!

The right side can be written as a single fraction, with common denominator 4a2. This gives

\left(x+\frac{b}{2a}\right)^2=\frac{b^2-4ac}{4a^2}.

Taking the square root of both sides yields

x+\frac{b}{2a}=\pm\frac{\sqrt{b^2-4ac\ }}{2a}.

Isolating x, gives

x=-\frac{b}{2a}\pm\frac{\sqrt{b^2-4ac\ }}{2a}=\frac{-b\pm\sqrt{b^2-4ac\ }}{2a}.

The symbol "±" indicates that both

 x=\frac{-b + \sqrt {b^2-4ac}}{2a}\quad\text{and}\quad x=\frac{-b - \sqrt {b^2-4ac}}{2a}

are solutions of the quadratic equation.[4]

Note: Some sources, particularly older ones, use alternative parameterizations such as ax2 − 2bx + c = 0 [5]:2 or ax2 + 2bx + c = 0, [6] where b has a magnitude one half of the more common one. These result in slightly different forms for the roots and discriminant, but are otherwise equivalent.

[ Discriminant

Example discriminant signs
<0: x2+12
=0: −43x2+43x13
>0: 32x2+12x43

In the above formula, the expression underneath the square root sign is called the discriminant of the quadratic equation, and is often represented using an upper case D or an upper case Greek delta:[7]

\Delta = b^2 - 4ac\,

A quadratic equation with real coefficients can have either one or two distinct real roots, or two distinct complex roots. In this case the discriminant determines the number and nature of the roots. There are three cases:

  • If the discriminant is positive, then there are two distinct roots
\frac{-b + \sqrt {\Delta}}{2a} \quad\text{and}\quad \frac{-b - \sqrt {\Delta}}{2a},
both of which are real numbers.
For quadratic equations with rational coefficients, if the discriminant is a square number, then the roots are rational—in other cases they may be quadratic irrationals.
  • If the discriminant is zero, then there is exactly one real root
-\frac{b}{2a} , \,
sometimes called a double root.
  • If the discriminant is negative, then there are no real roots. Rather, there are two distinct (non-real) complex roots[8]
 \frac{-b}{2a} + i \frac{\sqrt {-\Delta}}{2a} \quad\text{and}\quad \frac{-b}{2a} - i \frac{\sqrt {-\Delta}}{2a},
which are complex conjugates of each other. In these expressions i is the imaginary unit.

Thus the roots are distinct if and only if the discriminant is non-zero, and the roots are real if and only if the discriminant is non-negative.

[ Geometric interpretation

The solutions of the quadratic equation ax2 + bx + c = 0 are also the roots of the quadratic function:[9]

f(x) = ax^2+bx+c,\,

since they are the values of x for which

f(x) = 0.\,

If a, b, and c are real numbers and the domain of f is the set of real numbers, then the roots of f are exactly the x-coordinates of the points where the graph touches the x-axis.

It follows from the above that, if the discriminant is positive, the graph touches the x-axis at two points, if zero, the graph touches at one point, and if negative, the graph does not touch the x-axis.

[ Quadratic factorization

The term

x - r\,

is a factor of the polynomial

ax^2+bx+c, \

if and only if r is a root of the quadratic equation

ax^2+bx+c=0. \

It follows from the quadratic formula that

ax^2+bx+c = a \left( x - \frac{-b + \sqrt {b^2-4ac}}{2a} \right) \left( x - \frac{-b - \sqrt {b^2-4ac}}{2a} \right).

In the special case (b^2 = 4ac) where the quadratic has only one distinct root (i.e. the discriminant is zero), the quadratic polynomial can be factored as

ax^2+bx+c = a \left( x + \frac{b}{2a} \right)^2.\,\!

[ Graphing for real roots

For most of the twentieth century, graphing was rarely mentioned as a method for solving quadratic equations in high school or college algebra texts. Students learned to solve quadratic equations by factoring, completing the square, and applying the quadratic formula. Nowadays, with graphing calculators almost ubiquitous in schools, graphical methods of solution do show up in textbooks, but even so are usually not highly emphasized.[10]

Being able to use a graphing calculator to solve a quadratic equation requires the ability to produce a graph of y = f(x), the ability to scale the graph appropriately to the dimensions of the graphing surface, and the recognition that when f(x) = 0, x is a solution to the equation. The skills required to solve a quadratic equation on a calculator are in fact applicable to finding the real roots of any arbitrary function.

Since an arbitrary function may cross the x-axis at multiple points, graphing calculators generally require one to identify the desired root by positioning a cursor at a "guessed" value for the root. (Some graphing calculators require bracketing the root on both sides of the zero.) The calculator then proceeds, by an iterative algorithm, to refine the estimated position of the root to the limit of calculator accuracy.

[ Avoiding loss of significance

Although the quadratic formula provides what in principle should be an exact solution, it does not, from a numerical analysis standpoint, provide a completely stable method for evaluating the roots of a quadratic equation. If the two roots of the quadratic equation vary greatly in absolute magnitude, b will be very close in magnitude to \sqrt{b^2-4ac}, and the subtraction of two nearly equal numbers will cause loss of significance or catastrophic cancellation.

To avoid cancellation problems, a variant form of the quadratic formula can be employed where only numbers of the same sign are added:

\begin{align}
x_1 &= \frac{-b - \sgn (b) \,\sqrt {b^2-4ac}}{2a}, \\
x_2 &= \frac{2c}{-b - \sgn (b) \,\sqrt {b^2-4ac}} = \frac{c}{ax_1}.
\end{align}

Here sgn denotes the sign function, where sgn(b) is 1 if b is positive and −1 if b is negative.

To illustrate the instability of the standard quadratic formula versus this variant formula, consider a quadratic equation with roots 1.786737589984535 and 1.149782767465722×10-8. To sixteen significant figures, roughly corresponding to double-precision accuracy on a computer, the monic quadratic equation with these roots may be written as:
x2 − 1.786737601482363x + 2.054360090947453×10−8 = 0
Using the standard quadratic formula and maintaining sixteen significant figures at each step, the standard quadratic formula yields
Δ  = 1.786737578486707
x1 = (1.786737601482363 + 1.786737578486707) / 2 = 1.786737589984535
x2 = (1.786737601482363 − 1.786737578486707) / 2 = 0.000000011497828
Note how cancellation has resulted in x2 being computed to only eight significant digits of accuracy.
The variant formula presented here, however, yields the following:
x1 = (1.786737601482363 + 1.786737578486707) / 2 = 1.786737589984535
x2 = 2.054360090947453×10−8 / 1.786737589984535 = 1.149782767465722×10−8
Note the retention of all significant digits for x2.

Although the method described here represents an improvement over the standard quadratic formula, it does not resolve all issues associated with loss of significance.[11] See the Floating-point implementation section for a description of how solution of the quadratic equation would be implemented in a carefully written computer program.

[ History

Babylonian mathematicians, as early as 2000 BC (displayed on Old Babylonian clay tablets) could solve a pair of simultaneous equations of the form:

 x+y=p,\ \ xy=q \

which are equivalent to the equation:[12]:86

\ x^2+q=px

The original pair of equations were solved as follows:

  1. Form    \frac{x+y}{2}
  2. Form     \left(\frac{x+y}{2}\right)^2
  3. Form     \left(\frac{x+y}{2}\right)^2 - xy
  4. Form     \sqrt{\left(\frac{x+y}{2}\right)^2 - xy} = \frac{x-y}{2}      (where xy is assumed)
  5. Find x and y by inspection of the values in (1) and (4).[12]:87

There is evidence pushing this back as far as the Ur III dynasty.[13]

In the Sulba Sutras in ancient India circa 8th century BC quadratic equations of the form ax2 = c and ax2 + bx = c were explored using geometric methods. Babylonian mathematicians from circa 400 BC and Chinese mathematicians from circa 200 BC used the method of completing the square to solve quadratic equations with positive roots, but did not have a general formula.[citation needed]

Euclid, the Greek mathematician, produced a more abstract geometrical method around 300 BC. Pythagoras and Euclid used a strictly geometric approach, and found a general procedure to solve the quadratic equation. In his work Arithmetica, the Greek mathematician Diophantus solved the quadratic equation, but giving only one root, even when both roots were positive.[14]

In 628 AD, Brahmagupta, an Indian mathematician, gave the first explicit (although still not completely general) solution of the quadratic equation

\ ax^2+bx=c \,

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. (Brahmasphutasiddhanta, Colebrook translation, 1817, page 346)[12]:87

This is equivalent to:

x = \frac{\sqrt{4ac+b^2}-b}{2a}.

The Bakhshali Manuscript written in India in the 7th century AD contained an algebraic formula for solving quadratic equations, as well as quadratic indeterminate equations (originally of type ax/c = y).

Muhammad ibn Musa al-Khwarizmi (Persia, 9th century), inspired by Brahmagupta, developed a set of formulas that worked for positive solutions. Al-Khwarizmi goes further in providing a full solution to the general quadratic equation, accepting one or two numerical answers for every quadratic equation, while providing geometric proofs in the process.[15] He also described the method of completing the square and recognized that the discriminant must be positive,[15]:230 [16] which was proven by his contemporary 'Abd al-Hamīd ibn Turk (Central Asia, 9th century) who gave geometric figures to prove that if the discriminant is negative, a quadratic equation has no solution.[17] While al-Khwarizmi himself did not accept negative solutions, later Islamic mathematicians that succeeded him accepted negative solutions,[15]:191 as well as irrational numbers as solutions.[18] Abū Kāmil Shujā ibn Aslam (Egypt, 10th century) in particular was the first to accept irrational numbers (often in the form of a square root, cube root or fourth root) as solutions to quadratic equations or as coefficients in an equation.[19]

The Indian mathematician Sridhara, who flourished in the 9th and 10th centuries AC provided the modern solution of the quadratic equation.

The Jewish mathematician Abraham bar Hiyya Ha-Nasi (12th century, Spain) authored the first European book to include the full solution to the general quadratic equation.[20] His solution was largely based on Al-Khwarizmi's work.[15]:190–193 The writing of the Chinese mathematician Yang Hui (1238-1298 AD) represents the first in which quadratic equations with negative coefficients of 'x' appear, although he attributes this to the earlier Liu Yi.

By 1545 Gerolamo Cardano compiled the works related to the quadratic equations. The quadratic formula covering all cases was first obtained by Simon Stevin in 1594.[21] In 1637 René Descartes published La Géométrie containing the quadratic formula in the form we know today. The first appearance of the general solution in the modern mathematical literature appeared in a 1896 paper by Henry Heaton.[22]

[ Advanced topics

[ Other derivations of the quadratic formula

A number of alternative derivations of the quadratic formula can be found in the literature which either (a) are simpler than the standard completing the square method, (b) represent interesting applications of other frequently-used techniques in algebra, or (c) offer insight into other areas of mathematics.

[ Using an alternate method of completing the square

The great majority of algebra texts published over the last several decades teach completing the square using the sequence presented earlier: (1) divide each side by a, (2) rearrange, (3) then add the square of one-half of b/a.

However, as pointed out by Hoehn (1975), completing the square can accomplished by a different sequence that leads to a simpler sequence of intermediate terms: (1) multiply each side by 4a, (2) rearrange, (3) then add b2.[23]

In other words, the quadratic formula can be derived as follows:

ax^2+bx+c=0
4 a^2 x^2 + 4abx + 4ac=0
4 a^2 x^2 + 4abx = -4ac
4 a^2 x^2 + 4abx + b^2 = b^2 - 4ac
 (2ax + b)^2 = b^2 - 4ac
 2ax + b = \pm \sqrt{b^2-4ac}
 2ax = -b \pm \sqrt{b^2-4ac}
x=\frac{-b\pm\sqrt{b^2-4ac\ }}{2a}

This actually represents an ancient derivation of the quadratic formula, and was known to the Hindus at least as far back as 1025 A.D.[24] Compared with the derivation in standard usage, this alternate derivation is shorter, involves fewer computations with literal coefficients, avoids fractions until the last step, has simpler expressions, and uses simpler math. As Hoehn states, "it is easier 'to add the square of b' than it is 'to add the square of half the coeffient of the x term'".[23]

[ By Lagrange resolvents

An alternative way of deriving the quadratic formula is via the method of Lagrange resolvents, which is an early part of Galois theory.[25] 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 more than on rearranging the original equation. Given a monic quadratic polynomial

x^2+px+q,\!

assume that it factors as

x^2+px+q=(x-\alpha)(x-\beta).\!

Expanding yields

x^2+px+q=x^2-(\alpha+\beta)x+\alpha \beta,\!

where

p=-(\alpha+\beta)\!

and

q=\alpha \beta.\!

Since the order of multiplication does not matter, one can switch α and β and the values of p and q will not change: one says that p and q are symmetric polynomials in α and β. In fact, they are the elementary symmetric polynomials – any symmetric polynomial in α and β can be expressed in terms of α + β and αβ. The Galois theory approach to analyzing and solving polynomials is: given the coefficients of a polynomial, which are symmetric functions in the roots, can one "break the symmetry" and recover the roots? Thus solving a polynomial of degree n is related to the ways of rearranging ("permuting") n terms, which is called the symmetric group on n letters, and denoted S_n. For the quadratic polynomial, the only way to rearrange two terms is to swap them ("transpose" them), and thus solving a quadratic polynomial is simple.

To find the roots α and β, consider their sum and difference:

\begin{align}
r_1 &= \alpha + \beta\\
r_2 &= \alpha - \beta.\\
\end{align}

These are called the Lagrange resolvents of the polynomial; notice that one of these depends on the order of the roots, which is the key point. One can recover the roots from the resolvents by inverting the above equations:

\begin{align}
\alpha &= \textstyle{\frac{1}{2}}\left(r_1+r_2\right)\\
\beta  &= \textstyle{\frac{1}{2}}\left(r_1-r_2\right).\\
\end{align}

Thus, solving for the resolvents gives the original roots.

Formally, the resolvents are called the discrete Fourier transform (DFT) of order 2, and the transform can be expressed by the matrix \left(\begin{smallmatrix}1 & 1\\ 1 & -1\end{smallmatrix}\right), with inverse matrix \left(\begin{smallmatrix}1/2 & 1/2\\ 1/2 & -1/2\end{smallmatrix}\right). The transform matrix is also called the DFT matrix or Vandermonde matrix.

Now r_1=\alpha + \beta is a symmetric function in α and β, so it can be expressed in terms of p and q, and in fact r_1 = -p, as noted above. But r_2=\alpha - \beta is not symmetric, since switching α and β yields -r_2=\beta - \alpha (formally, this is termed a group action of the symmetric group of the roots). Since r_2 is not symmetric, it cannot be expressed in terms of the polynomials p and q, as these are symmetric in the roots and thus so is any polynomial expression involving them. However, changing the order of the roots only changes r_2 by a factor of -1, and thus the square \scriptstyle r_2^2 = (\alpha - \beta)^2 is symmetric in the roots, and thus expressible in terms of p and q. Using the equation

(\alpha - \beta)^2 = (\alpha + \beta)^2 - 4\alpha\beta\!

yields

r_2^2 = p^2 - 4q\!

and thus

r_2 = \pm \sqrt{p^2 - 4q}\!.

If one takes the positive root, breaking symmetry, one obtains:

\begin{align}
r_1 &= -p\\
r_2 &= \sqrt{p^2 - 4q}\\
\end{align}

and thus

\begin{align}
\alpha &= \textstyle{\frac{1}{2}}\left(-p+\sqrt{p^2 - 4q}\right)\\
\beta  &= \textstyle{\frac{1}{2}}\left(-p-\sqrt{p^2 - 4q}\right)\\
\end{align}

Thus the roots are

\textstyle{\frac{1}{2}}\left(-p \pm \sqrt{p^2 - 4q}\right)

which is the quadratic formula. Substituting \scriptstyle p=\tfrac{b}{a}, q=\tfrac{c}{a}\! yields the usual form for when a quadratic is not monic. The resolvents can be recognized as \scriptstyle \frac{r_1}{2} = \frac{-p}{2}=\frac{-b}{2a}\! being the vertex, and \scriptstyle r_2^2=p^2-4q\! is the discriminant (of a monic polynomial).

A similar but more complicated method works for cubic equations, where one has three resolvents and a quadratic equation (the "resolving polynomial") relating r_2 and r_3, which one can solve by the quadratic equation, and similarly for a quartic (degree 4) equation, whose resolving polynomial is a cubic, which can in turn be solved. However, 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.

[ Other methods of root calculation

[ Alternative quadratic formula

In some situations it is preferable to express the roots in an alternative form.

x =\frac{2c}{-b \mp \sqrt {b^2-4ac\ }} = \frac{2c}{-b \mp \sqrt \Delta}.

This alternative requires c to be nonzero; for, if c is zero, the formula correctly gives zero as one root, but fails to give any second, non-zero root. Instead, one of the two choices for ∓ produces the indeterminate form 0/0, which is undefined. However, the alternative form works when a is zero (giving the unique solution as one root and division by zero again for the other), which the normal form does not (instead producing division by zero both times).

The roots are the same regardless of which expression we use; the alternative form is merely an algebraic variation of the common form:

\begin{align}
\frac{-b \pm \sqrt {b^2-4ac\ }}{2a}
 &{}= \frac{-b \pm \sqrt {b^2-4ac\ }}{2a} \cdot \frac{-b \mp \sqrt {b^2-4ac\ }}{-b \mp \sqrt {b^2-4ac\ }} \\
 &{}= \frac{b^2 - (b^2 - 4ac)}{2a \left ( -b \mp \sqrt {b^2-4ac} \right ) } \\
 &{}= \frac{4ac}{2a \left ( -b \mp \sqrt {b^2-4ac} \right ) } \\
 &{}=\frac{2c}{-b \mp \sqrt {b^2-4ac\ }}.
\end{align}

[ Floating-point implementation

A careful floating point computer implementation combines several strategies to produce a robust result. Assuming the discriminant, b2 − 4ac, is positive and b is nonzero, the code will be something like the following:[26]

q = -\tfrac12 \left( b + \sgn(b) \sqrt{b^2-4ac} \right) \,\!
x_1 = q/a \,\!
x_2 = c/q \,\!

Here sgn(b) is the sign function, where sgn(b) is 1 if b is positive and −1 if b is negative; its use ensures that the quantities added are of the same sign, avoiding catastrophic cancellation. The computation of x2 uses the fact that the product of the roots is c/a. Note that while the above formulation avoids catastrophic cancellation between b and \sqrt{b^2-4ac}, there remains a form of cancellation between the terms b2 and −4ac of the discriminant, which can still lead to loss of up to half of correct significant figures.[5][11] The discriminant b2−4ac needs to be computed in arithmetic of twice the precision of the result to avoid this (e.g. quad precision if the final result is to be accurate to full double precision).[27] This can be in the form of a fused multiply-add operation.[5]

To illustrate this, consider the following quadratic equation, adapted from Kahan (2004):[5]
94906265.625x2 − 189812534x + 94906268.375
This equation has Δ = 7.5625 and has roots
x1 = 1.000000028975958
x2 = 1.000000000000000.
However, when computed using IEEE 754 double-precision arithmetic corresponding to 15 to 17 significant digits of accuracy, Δ is rounded to 0.0, and the computed roots are
x1 = 1.000000014487979
x2 = 1.000000014487979
which are both false after the eighth significant digit. This is despite the fact that superficially, the problem seems to require only eleven significant digits of accuracy for its solution.

[ Vieta's formulas

Vieta's formulas give a simple relation between the roots of a polynomial and its coefficients. In the case of the quadratic polynomial, they take the following form:

 x_1 + x_2 = -\frac{b}{a}

and

 x_1 \ x_2 = \frac{c}{a}.

These results follow immediately from the relation:

\left( x - x_1 \right) \ \left( x-x_2 \right ) = x^2 \ - \left( x_1+x_2 \right)x +x_1 \ x_2 \ = 0 \ ,

which can be compared term by term with:

 x^2 + (b/a)x +c/a = 0 \ .

The first formula above yields a convenient expression when graphing a quadratic function. Since the graph is symmetric with respect to a vertical line through the vertex, when there are two real roots the vertex’s x-coordinate is located at the average of the roots (or intercepts). Thus the x-coordinate of the vertex is given by the expression:

 x_V = \frac {x_1 + x_2} {2} = -\frac{b}{2a}.

The y-coordinate can be obtained by substituting the above result into thee given quadratic equation, giving

 y_V = - \frac{b^2}{4a} + c = - \frac{ b^2 - 4ac} {4a}.CC-BY-SA.