Solving Quadratic Equations: Factoring, Completing the Square,
formula.
Three methods for solving ax² + bx + c = 0, each worked through an example, plus how the discriminant tells you what kind of roots to expect.
A quadratic equation is any equation that can be written as ax² + bx + c = 0 with a ≠ 0. The values of x that satisfy it are its roots, and on a graph they are the points where the parabola y = ax² + bx + c crosses the x-axis. There are three standard methods for finding them: factoring, completing the square and the quadratic formula. Each one is worked through below, followed by the discriminant, which tells you what kind of roots to expect before you start.
Before you start: standard form
Every method assumes the equation is in standard form, with everything on one side and zero on the other. Rearrange first: 3x² = 2x + 8 becomes 3x² − 2x − 8 = 0, so a = 3, b = −2 and c = −8. Keep the signs with the coefficients. Most errors in solving quadratics come from dropping a minus sign at this step, not from the method itself.
Method 1: factoring
Factoring rests on the zero product property: if two numbers multiply to zero, at least one of them is zero. If you can write the quadratic as a product of two linear factors, each factor gives a root.
When a = 1
For x² − 5x + 6 = 0, look for two numbers that multiply to c = 6 and add to b = −5. The pair is −2 and −3: (−2) × (−3) = 6 and (−2) + (−3) = −5. So the equation factors as (x − 2)(x − 3) = 0, and the roots are x = 2 and x = 3.
When a ≠ 1: the ac method
For 2x² + 7x + 3 = 0:
- Multiply a and c: 2 × 3 = 6.
- Find two numbers that multiply to 6 and add to b = 7: they are 6 and 1.
- Split the middle term: 2x² + 6x + x + 3 = 0.
- Group and factor each pair: 2x(x + 3) + 1(x + 3) = 0, so (2x + 1)(x + 3) = 0.
- Solve each factor: x = −0.5 or x = −3.
Special patterns
A difference of squares factors directly: x² − 9 = 0 is (x + 3)(x − 3) = 0, so x = ±3. A perfect square trinomial such as x² + 6x + 9 is (x + 3)², which gives one repeated root. And when c = 0, x is always a common factor: x² − 7x = x(x − 7), so x = 0 or x = 7.
Factoring is the fastest method when it works, but it only works neatly when the roots are rational. Most quadratics that come from real measurements do not factor over the integers, and that is where the other two methods come in. The polynomial long division calculator is useful for checking a factor you suspect.
Method 2: completing the square
Completing the square rewrites the quadratic so that x appears only once, inside a squared bracket, and then undoes the square with a square root. It works for every quadratic. Take 2x² + 8x − 5 = 0:
- Divide by a = 2 so the x² coefficient is 1: x² + 4x − 2.5 = 0.
- Move the constant to the right: x² + 4x = 2.5.
- Take half the x coefficient and square it: (4 ÷ 2)² = 4. Add it to both sides: x² + 4x + 4 = 6.5.
- The left side is now a perfect square: (x + 2)² = 6.5.
- Take the square root of both sides, remembering both signs: x + 2 = ±√6.5.
- Solve: x = −2 ± √6.5, which is x = 0.5495 or x = −4.5495.
The same process gives the vertex form of the parabola, y = a(x − h)² + k, where (h, k) is the vertex. For this example it is y = 2(x + 2)² − 13, so the lowest point of the graph is at (−2, −13). That makes completing the square the method of choice when you need the vertex, for instance to find the maximum height of a projectile or the minimum cost on a quadratic cost curve. The completing the square calculator shows each of these steps for any equation.
The method is old. The ninth-century mathematician Muhammad ibn Musa al-Khwarizmi solved quadratics this way in his book on al-jabr, literally drawing a square and adding the missing corner pieces to complete it. The word algebra comes from the title of that book.
Method 3: the quadratic formula
Completing the square on the general equation ax² + bx + c = 0, with letters instead of numbers, produces the quadratic formula:
x = (−b ± √(b² − 4ac)) ÷ 2a
Briefly: divide by a, move c ÷ a across, add (b ÷ 2a)² to both sides, and the left side becomes (x + b ÷ 2a)² while the right side simplifies to (b² − 4ac) ÷ 4a². Taking the square root and subtracting b ÷ 2a gives the formula. It always works, which makes it the safe default when factoring is not obvious.
Worked example: a thrown ball
A ball is thrown upward at 20 m/s from a height of 1.5 m. Using g ≈ 9.8 m/s², its height after t seconds is h = −4.9t² + 20t + 1.5. When does it hit the ground? Set h = 0, so a = −4.9, b = 20, c = 1.5.
- Discriminant: b² − 4ac = 400 − 4 × (−4.9) × 1.5 = 400 + 29.4 = 429.4.
- Square root: √429.4 = 20.722.
- Denominator: 2a = −9.8.
- Roots: t = (−20 ± 20.722) ÷ (−9.8), which gives t = 4.1553 and t = −0.0737.
The negative root is a real solution of the equation but not of the physical problem, since the ball was thrown at t = 0. The ball lands after about 4.16 seconds. The vertex, at t = −b ÷ 2a = 2.04 s, gives the maximum height of 21.91 m. Discarding roots that make no sense in context is a normal part of applying the formula. The quadratic solver shows these steps, the vertex and the graph for any coefficients.
The discriminant
The expression under the square root, Δ = b² − 4ac, is the discriminant. You can compute it before solving to learn what kind of roots you will get:
- Δ > 0: two different real roots. The parabola crosses the x-axis twice. If Δ is a perfect square and a, b, c are integers, the roots are rational and the quadratic factors.
- Δ = 0: one repeated real root, x = −b ÷ 2a. The vertex sits exactly on the x-axis.
- Δ < 0: no real roots. The parabola never touches the x-axis, and the roots are a pair of complex conjugates.
Chart data as a table
| x | y = x² − 2x − 3 | y = x² − 2x + 1 | y = x² − 2x + 3 |
|---|---|---|---|
| -2.5 | 8.25 | 12.25 | 14.25 |
| -2 | 5 | 9 | 11 |
| -1.5 | 2.25 | 6.25 | 8.25 |
| -1 | 0 | 4 | 6 |
| -0.5 | -1.75 | 2.25 | 4.25 |
| 0 | -3 | 1 | 3 |
| 0.5 | -3.75 | 0.25 | 2.25 |
| 1 | -4 | 0 | 2 |
| 1.5 | -3.75 | 0.25 | 2.25 |
| 2 | -3 | 1 | 3 |
| 2.5 | -1.75 | 2.25 | 4.25 |
| 3 | 0 | 4 | 6 |
| 3.5 | 2.25 | 6.25 | 8.25 |
| 4 | 5 | 9 | 11 |
| 4.5 | 8.25 | 12.25 | 14.25 |
| Equation | Δ = b² − 4ac | Roots |
|---|---|---|
| x² − 2x − 3 = 0 | 16 | x = −1 and x = 3 |
| x² − 2x + 1 = 0 | 0 | x = 1 (repeated) |
| x² − 2x + 3 = 0 | −8 | x = 1 ± 1.4142i |
For the third equation the formula gives x = (2 ± √−8) ÷ 2. Writing √−8 as 2√2 i, the roots are 1 ± √2 i, or x = 1 ± 1.4142i. In a physics or geometry problem, a negative discriminant usually means the situation cannot happen: a ball that never reaches a given height, for example.
Checking your answer
Substituting a root back into the equation should give zero. A quicker check uses Vieta's formulas: the roots of ax² + bx + c = 0 always add to −b ÷ a and multiply to c ÷ a. For the ball, the roots sum to 4.0816 and −b ÷ a = 4.0816; they multiply to −0.3061 and c ÷ a = −0.3061. If both agree, the arithmetic is right.
Which method should you use?
| Situation | Best method |
|---|---|
| Small integer coefficients and Δ is a perfect square | Factoring |
| c = 0, or b = 0 | Factor out x, or isolate x² and take a square root |
| You need the vertex or vertex form | Completing the square |
| Decimal coefficients, or no obvious factors | Quadratic formula |
| You only need to know how many real roots there are | Compute the discriminant |
A sensible routine is to compute the discriminant first. If it is a perfect square, try factoring; otherwise go straight to the formula. For equations of higher degree, the cubic equation solver handles the next step up, and the polynomial evaluator checks values at any x.
A note on calculators and rounding
The textbook formula can lose accuracy on a computer when b² is much larger than 4ac, because −b and √Δ are then nearly equal and subtracting them cancels most of the significant digits. For x² − 100,000,000x + 1 = 0, the small root is very close to 0.00000001. Evaluating the formula directly in standard double-precision arithmetic gives 7.450581e-9, which is off by about 25%. The fix, described in Numerical Recipes, is to compute the larger root with the formula and the smaller one from Vieta's product, c ÷ (a × x₁). That gives 1.000000e-8. The quadratic solver on this site uses the stable version. When working by hand, keep a few extra digits in √Δ until the last step.
Sources
- Abramson J. College Algebra 2e. OpenStax, Rice University, 2021. Section 2.5, Quadratic Equations.
- Stewart J, Redlin L, Watson S. Precalculus: Mathematics for Calculus, 7th edition. Cengage, 2016. Section 1.5, Equations (solving quadratic equations).
- Press WH, Teukolsky SA, Vetterling WT, Flannery BP. Numerical Recipes: The Art of Scientific Computing, 3rd edition. Cambridge University Press, 2007. Section 5.6, Quadratic and Cubic Equations.
- Goldberg D. What every computer scientist should know about floating-point arithmetic. ACM Computing Surveys, 1991; 23(1): 5-48.
- Katz VJ. A History of Mathematics: An Introduction, 3rd edition. Addison-Wesley, 2009. Chapter 9 (al-Khwarizmi and the solution of quadratic equations).