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 , with representing an unknown, and coefficients , , and representing known real or complex numbers with , the values of satisfying the equation, called the roots or zeros, can be found using the quadratic formula,

where the plus–minus symbol "" indicates that the equation has two roots. Written separately, these are:

The quantity is known as the discriminant of the quadratic equation. If the coefficients , , and are real numbers then when , the equation has two distinct real roots; when , the equation has one repeated real root; and when , the equation has no real roots but has two distinct complex roots, which are complex conjugates of each other.

Geometrically, the roots represent the values at which the graph of the quadratic function , a parabola, crosses the -axis: the graph's -intercepts. The quadratic formula can also be used to identify the parabola's axis of symmetry.

Derivation by completing the square

The standard way to derive the quadratic formula is to apply the method of completing the square to the generic quadratic equation .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."Rockswold, Gary. College algebra and trigonometry and precalculus, p. 178 (Addison Wesley, 2002).Beckenbach, Edwin et al. Modern college algebra and trigonometry, p. 81 (Wadsworth Pub. Co., 1986). The idea is to transform the equation into the form for some expressions and written in terms of the coefficients; take the square root of both sides; and then isolate .

We start by dividing the equation by the quadratic coefficient , which is allowed because is non-zero. Afterwards, we subtract the constant term to isolate it on the right-hand side:

The left-hand side is now of the form , and we can "complete the square" by adding a constant to obtain a squared binomial . In this example we add to both sides so that the left-hand side can be factored (see the figure):

Because the left-hand side is now a perfect square, we can easily take the square root of both sides:

Finally, subtracting from both sides to isolate produces the quadratic formula:

Equivalent formulations The quadratic formula can equivalently be written using various alternative expressions, for instance

which can be derived by first dividing a quadratic equation by , resulting in , then substituting the new coefficients into the standard quadratic formula. Because this variant allows re-use of the intermediately calculated quantity , it can slightly reduce the arithmetic involved.

Square root in the denominator A lesser known quadratic formula, first mentioned by Giulio Fagnano,Specifically, Fagnano began with the equation and found the solutions to be (In the 18th century, the square was conventionally written as describes the same roots via an equation with the square root in the denominator (assuming ):

Here the minus–plus symbol "" indicates that the two roots of the quadratic equation, in the same order as the standard quadratic formula, are

This variant has been jokingly called the "citardauq" formula ("quadratic" spelled backwards).

When has the opposite sign as either or , 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 can avoid this problem. See 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 , one of Vieta's formulas. Alternately, it can be derived by dividing each side of the equation by to get , applying the standard formula to find the two roots , and then taking the reciprocal to find the roots of the original equation.

Other derivations 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 method Instead of dividing by to isolate , it can be slightly simpler to multiply by instead to produce , which allows us to complete the square without need for fractions. Then the steps of the derivation are:

Multiply each side by . Add to both sides to complete the square. Take the square root of both sides. Isolate .

Applying this method to a generic quadratic equation with symbolic coefficients yields the quadratic formula:

This method for completing the square is ancient and was known to the 8th–9th century Indian mathematician Śrīdhara.Starting from a quadratic equation of the form , Ś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.]". 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.

By substitution Another derivation uses a change of variables to eliminate the linear term. Then the equation takes the form in terms of a new variable and some constant expression , whose roots are then .

By substituting into , expanding the products and combining like terms, and then solving for , we have:

Finally, after taking a square root of both sides and substituting the resulting expression for back into the familiar quadratic formula emerges:

By using algebraic identities The following method was used by many historical mathematicians:

Let the roots of the quadratic equation be and . 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:

Since the coefficient , we can divide the quadratic equation by to obtain a monic polynomial with the same roots. Namely,

This implies that the sum and the product . Thus the identity can be rewritten:

Therefore,

The two possibilities for each of and are the same two roots in opposite order, so we can combine them into the standard quadratic equation:

By Lagrange resolvents

An alternative way of deriving the quadratic formula is via the method of Lagrange resolvents,Clark, A. (1984). Elements of abstract algebra. Courier Corporation. p. 146. 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 themselves rather than algebraically rearranging the original equation. Given a monic quadratic polynomial assume that and are the two roots. So the polynomial factors as

which implies and .

Since multiplication and addition are both commutative, exchanging the roots and will not change the coefficients and : one can say that and are symmetric polynomials in and . Specifically, they are the elementary symmetric polynomials – any symmetric polynomial in and can be expressed in terms of and 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 is related to the ways of rearranging ("permuting") terms, called the symmetric group on letters and denoted . 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 and , consider their sum and difference:

These are called the Lagrange resolvents of the polynomial, from which the roots can be recovered as

Because is a symmetric function in and , it can be expressed in terms of and specifically as described above. However, is not symmetric, since exchanging and yields the additive inverse . So cannot be expressed in terms of the symmetric polynomials. However, its square is symmetric in the roots, expressible in terms of and . Specifically , which implies . Taking the positive root "breaks" the symmetry, resulting in

from which the roots and are recovered as

which is the quadratic formula for a monic polynomial.

Substituting , yields the usual expression for an arbitrary quadratic polynomial. The resolvents can be recognized as

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 and , 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. 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 calculation

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 if ; catastrophic calculation in computing the discriminant itself in cases where ; degeneration of the formula when , , or 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.

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 , evaluation of causes catastrophic cancellation, as does the evaluation of when . 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.

For example, if trying to solve the equation using a pocket calculator, the result of the quadratic formula might be approximately calculated as:This example comes from: