In mathematics, a quadratic equation
is a univariate polynomial equation of the second degree. A general quadratic equation can be written in the form
represents a variable or an unknown, and a
, and c
are constants with a
not equal to 0. (If a
= 0, the equation is a linear equation.) Dividing the above equation by a
gives the simplified monic form
The constants a
, and c
are called, respectively, the quadratic coefficient, the linear coefficient and the constant or free term. Quadratic equations can be solved by factoring (or "factorising" in British English), completing the square, using the quadratic formula, and graphing.
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.
A quadratic equation in
form can always be expressed as a product
. In many cases, it is possible, by simple inspection, to determine values of p
that will allow writing the left side of the quadratic equation in factored form. If the quadratic equation is written in factored form, then the "Zero Factor Property" states that the quadratic equation is satisfied if px
= 0 or rx
= 0. Solving these two linear equations provides the roots of the quadratic.
For most students, factoring by inspection is the first method of solving quadratic equations to which they are exposed.:202–207 If one is given a quadratic equation in monic form,
, one would seek to find two numbers that add up to b
and whose product is c
("Vieta's Rule"). The more general case where a
does not equal 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 by inspection.:207
Completing the square makes use of the algebraic identity
which represents a well-defined algorithm that can be used to solve any quadratic equation.:207 Starting with a quadratic equation in standard form,
We illustrate use of this algorithm by solving
Completing the square can be used to derive a general formula for solving quadratic equations, the quadratic formula.
Dividing the quadratic equation
, which is allowed because a
is non-zero, gives
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:
The right side can be written as a single fraction with common denominator
. This gives
Taking the square root of both sides yields
The plus-minus symbol "±" indicates that both
are solutions of the quadratic equation.
Some sources, particularly older ones, use alternative parameterizations such as
, 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.
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:
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:
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.
is the quadratic function. The graph of any quadratic function has the same general shape, which is called a parabola. The location and size of the parabola, and how it opens, depends on the values of a
, and c
. As shown in Figure 1, if a
> 0, the parabola has a minimum point and opens upward. If a
< 0, the parabola has a maximum point and opens downward. The extreme point of the parabola, whether minimum or maximum, corresponds to its vertex. The x-coordinate
of the vertex will be located at
, and the y-coordinate
of the vertex may be found by substituting this x-value
into the function. The y-intercept
is located at the point (0,c
The solutions of the quadratic equation
correspond to the roots of the function
, since they are the values of x
. As shown in Figure 2, if a
, 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. As shown in Figure 3, if the discriminant is positive, the graph touches the -axisx
at two points; if zero, the graph touches at one point; and if negative, the graph does not touch the x
is a factor of the polynomial
if and only if r
is a root of the quadratic equation
It follows from the quadratic formula that
In the special case
where the quadratic has only one distinct root (i.e.
the discriminant is zero), the quadratic polynomial can be factored as
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. Recently, graphing calculators have become more common in schools and graphical methods have started to appear in textbooks, but they are generally not highly emphasized. Graphical methods can only produce an approximate solution in the case of irrational roots.
Being able to use a graphing calculator to solve a quadratic equation requires the ability to produce a graph of y
), the ability to scale the graph appropriately to the dimensions of the graphing surface, and the recognition that when f
) = 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.
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
, and the subtraction of two nearly equal numbers will cause loss of significance or catastrophic cancellation. A second form of cancellation can occur between the terms
of the discriminant, which can lead to loss of up to half of correct significant figures.
See the Floating-point implementation section for a description of how loss of significance issues would be handled in a carefully written computer program.
Babylonian mathematicians, as early as 2000 BC (displayed on Old Babylonian clay tablets) could solve problems relating the areas and sides of rectangles. In modern notation, the problems typically involved solving a pair of simultaneous equations of the form:
which are equivalent to the equation::86
The steps given by Babylonian scribes for solving the above rectangle problem were as follows:
Note that step (5) is essentially equivalent to calculating
There is evidence dating this algorithm as far back as the Ur III dynasty.
In the Sulba Sutras in ancient India circa 8th century BC quadratic equations of the form
were explored using geometric methods. Babylonian mathematicians from circa 400 BC and Chinese mathematicians from circa 200 BC used geometric methods of dissection to solve quadratic equations with positive roots, but do not appear to have had a general formula.
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.
In 628 AD, Brahmagupta, an Indian mathematician, gave the first explicit (although still not completely general) solution of the quadratic equation
This is equivalent to:
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
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. He also described the method of completing the square and recognized that the discriminant must be positive,:230 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.:234 While al-Khwarizmi himself did not accept negative solutions, later Islamic mathematicians that succeeded him accepted negative solutions,:191 as well as irrational numbers as solutions. 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.
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. His solution was largely based on Al-Khwarizmi's work. 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. 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.
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.
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 Larry Hoehn in 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
In other words, the quadratic formula can be derived as follows:
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. 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 coefficient of the x
An alternative way of deriving the quadratic formula is via the method of Lagrange resolvents, which is an early part of Galois theory. 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
assume that it factors as
Since the order of multiplication does not matter, one can switch
and the values of p
will not change: one says that p
are symmetric polynomials in
. In fact, they are the elementary symmetric polynomials – any symmetric polynomial in
can be expressed in terms of
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
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
consider their sum and difference:
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:
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
with inverse matrix
The transform matrix is also called the DFT matrix or Vandermonde matrix.
is a symmetric function in
so it can be expressed in terms of p
and in fact
as noted above. But
is not symmetric, since switching
(formally, this is termed a group action of the symmetric group of the roots). Since
is not symmetric, it cannot be expressed in terms of the polynomials p
, 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
by a factor of
and thus the square is
symmetric in the roots, and thus expressible in terms of p
Using the equation
If one takes the positive root, breaking symmetry, one obtains:
Thus the roots are
which is the quadratic formula. Substituting
yields the usual form for when a quadratic is not monic. The resolvents can be recognized as
being the vertex, and
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
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.
A careful floating point computer implementation combines several strategies to produce a robust result. Assuming the discriminant, , is positive and b
is nonzero, the computation would be as follows:
Here sgn denotes the sign function, where sgn(b) is 1 if b is positive and −1 if b is negative. This avoids cancellation problems between b and the square root of the discriminant by ensuring that only numbers of the same sign are added.
To illustrate the instability of the standard quadratic formula versus
this variant formula, consider a quadratic equation with roots
. To sixteen significant figures, roughly corresponding to double-precision accuracy on a computer, the monic quadratic equation with these roots may be written as:
Using the standard quadratic formula and maintaining sixteen significant figures at each step, the standard quadratic formula yields
Note how cancellation has resulted in
being computed to only eight significant digits of accuracy. The variant formula presented here, however, yields the following:
Note the retention of all significant digits for
Note that while the above formulation avoids catastrophic cancellation between b
, there remains a form of cancellation between the terms
of the discriminant, which can still lead to loss of up to half of correct significant figures. The discriminant
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). This can be in the form of a fused multiply-add operation.
To illustrate this, consider the following quadratic equation, adapted from Kahan (2004):
This equation has
and has roots
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
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 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:
These results follow immediately from the relation:
which can be compared term by term with
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
The y-coordinate can be obtained by substituting the above result into the given quadratic equation, giving
As a practical matter, Vieta's formulas provide a useful method for finding the roots of a quadratic in the case where one root is much smaller than the other. If |x 2
| << |x 1
|, then x 1
+ x 2
≈ x 1
, and we have the estimate:
The second Vieta's formula then provides:
These formulas are much easier to evaluate than the quadratic formula under the condition of one large and one small root, because the quadratic formula evaluates the small root as the difference of two very nearly equal numbers (the case of large b
), which causes round-off error in a numerical evaluation. Figure 5 shows the difference between (i) a direct evaluation using the quadratic formula (accurate when the roots are near each other in value) and (ii) an evaluation based upon the above approximation of Vieta's formulas (accurate when the roots are widely spaced). As the linear coefficient b
increases, initially the quadratic formula is accurate, and the approximate formula improves in accuracy, leading to a smaller difference between the methods as b
increases. However, at some point the quadratic formula begins to lose accuracy because of round off error, while the approximate method continues to improve. Consequently the difference between the methods begins to increase as the quadratic formula becomes worse and worse.
This situation arises commonly in amplifier design, where widely separated roots are desired to ensure a stable operation (see step response).
In the days before calculators, people would use mathematical tables—lists of numbers showing the results of calculation with varying arguments—to simplify and speed up computation. Tables of logarithms and trigonometric functions were common in math and science textbooks. Specialized tables were published for applications such as astronomy, celestial navigation and statistics. Methods of numerical approximation existed, called prosthaphaeresis, that offered shortcuts around time-consuming operations such as multiplication and taking powers and roots. Astronomers, especially, were concerned with methods that could speed up the long series of computations involved in celestial mechanics calculations.
It is within this context that we may understand the development of means of solving quadratic equations by the aid of trigonometric substitution. Consider the following alternate form of the quadratic equation,
where the sign of the ± symbol is chosen so that a
may both be positive. By substituting
and then multiplying through by
Introducing functions of
and rearranging, we obtain
where the subscripts n
correspond, respectively, to the use of a negative or positive sign in equation 
. Substituting the two values of
found from equations 
gives the required roots of 
. Complex roots occur in the solution based on equation 
if the absolute value of
exceeds unity. The amount of effort involved in solving quadratic equations using this mixed trigonometric and logarithmic table look-up strategy was two-thirds the effort using logarithmic tables alone. Calculating complex roots would require using a different trigonometric form.
The quadratic equation may be solved geometrically in a number of ways. One way is via Lill's method. The three coefficients a
are drawn with right angles between them as in SA, AB, and BC in Figure 6. A circle is drawn with the start and end point SC as a diameter. If this cuts the middle line AB of the three then the equation has a solution, and the solutions are given by negative of the distance along this line from A divided by the first coefficient a
or SA. If a
is 1 the coefficients may be read off directly. Thus the solutions in the diagram are −AX1/SA and −AX2/SA.
The formula and its derivation remain correct if the coefficients a
are complex numbers, or more generally members of any field whose characteristic is not 2. (In a field of characteristic 2, the element 2a
is zero and it is impossible to divide by it.)
in the formula should be understood as "either of the two elements whose square is
, if such elements exist". In some fields, some elements have no square roots and some have two; only zero has just one square root, except in fields of characteristic 2. Note that even if a field does not contain a square root of some number, there is always a quadratic extension field which does, so the quadratic formula will always make sense as a formula in that extension field.
In a field of characteristic 2, the quadratic formula, which relies on 2 being a unit, does not hold. Consider the monic quadratic polynomial
over a field of characteristic 2. If
, then the solution reduces to extracting a square root, so the solution is
and note that there is only one root since
See quadratic residue for more information about extracting square roots in finite fields.
In the case that
, there are two distinct roots, but if the polynomial is irreducible, they cannot be expressed in terms of square roots of numbers in the coefficient field. Instead, define the 2-root R
) of c
to be a root of the polynomial
an element of the splitting field of that polynomial. One verifies that R
) + 1 is also a root. In terms of the 2-root operation, the two roots of the (non-monic) quadratic
For example, let a
denote a multiplicative generator of the group of units of
the Galois field of order four (thus a
+ 1 are roots of
+ 1 is the unique solution of the quadratic equation
On the other hand, the polynomial
is irreducible over
but it splits over
where it has the two roots ab
, where b
is a root of
This is a special case of Artin-Schreier theory.