---
title: "How to Solve Quadratic Equations: 3 Methods with Examples"
description: "Solve quadratic equations by factorising, the quadratic formula and completing the square, with the discriminant, a real example and Python checks."
slug: how-to-solve-quadratic-equations
canonical: https://learn.modernagecoders.com/blog/how-to-solve-quadratic-equations/
date: 2026-09-28
dateModified: 2026-09-28
category: "Mathematics"
tags: ["Algebra", "GCSE", "Quadratics", "Python"]
keywords: ["how to solve quadratic equations", "quadratic formula", "factorising quadratics", "completing the square", "discriminant", "quadratic equation examples", "quadratic equations gcse"]
readTime: "8 min read"
author: "Modern Age Coders Team"
---
# How to Solve Quadratic Equations: 3 Methods with Examples

> Factorising, the quadratic formula and completing the square, when to use each, what the discriminant tells you, and a thrown ball that shows why two answers make sense.

![How to solve quadratic equations: the quadratic formula x equals minus b plus or minus root b squared minus 4ac over 2a](/images/blog/how-to-solve-quadratic-equations/00-hero.png)

*By Modern Age Coders Team · 2026-09-28 · 8 min read*

**Quick answer:** A quadratic equation can be written ax squared + bx + c = 0. Factorise when two numbers multiply to c and add to b; use the quadratic formula x = (-b plus or minus the square root of b squared - 4ac) / 2a for anything; complete the square to find the turning point. The discriminant b squared - 4ac gives two solutions if positive, one if zero, none if negative. Two answers often both make sense, like a thrown ball passing 15 m at 1 second and 3 seconds. Always substitute your answers back to check.

A quadratic equation is any equation that can be written as ax² + bx + c = 0, where a is not zero. The x² is what makes it quadratic, and it is why these equations usually have two answers rather than one. They turn up everywhere from the path of a thrown ball to the area of a garden, and they are a core topic in GCSE, IGCSE, Class 10 CBSE and US Algebra 1.

This guide covers the three standard methods, factorising, the quadratic formula and completing the square, with worked examples and a clear way to choose between them. A few lines of Python check every answer, and a real-world example shows why getting two answers makes perfect sense.

## What makes an equation quadratic

In ax² + bx + c = 0, the letters a, b and c are numbers, called coefficients. For x² − 5x + 6 = 0, a = 1, b = −5 and c = 6. Always rearrange so one side is zero before you start; for example, x² = 5x − 6 must become x² − 5x + 6 = 0. The graph of y = ax² + bx + c is a U-shaped curve called a parabola, and the solutions are where it crosses the x-axis.

## Method 1: factorising

If you can write the quadratic as two brackets multiplied together, the solutions come straight out, because if two things multiply to zero, one of them must be zero. For x² + bx + c, look for two numbers that **multiply to c** and **add to b**.

![Factorising x squared minus 5x plus 6: of the pairs that multiply to 6, only minus 2 and minus 3 also add to minus 5, so the equation factorises to (x minus 2)(x minus 3) and x = 2 or 3](/images/blog/how-to-solve-quadratic-equations/02-factorise.png)

*Try the pairs that multiply to c until one also adds to b.*

For x² − 5x + 6: the pairs that multiply to 6 are 1 and 6, 2 and 3, −1 and −6, −2 and −3. Only −2 and −3 add to −5. So x² − 5x + 6 = (x − 2)(x − 3) = 0, giving x = 2 or x = 3. A computer can do the same search:

**factor.py**

```python
from formula import show

# Factorise x^2 + bx + c: find two whole numbers that multiply to c and add to b
def factor_pair(b, c):
    for p in range(-abs(c), abs(c) + 1):
        if p != 0 and c % p == 0 and p + c // p == b:
            return p, c // p
    return None

for b, c in [(-5, 6), (1, -12), (7, 10), (2, -4)]:
    pair = factor_pair(b, c)
    if pair:
        p, q = pair
        bracket = lambda n: f"(x {'-' if n < 0 else '+'} {abs(n)})"
        print(f"{show(1, b, c)} = {bracket(p)}{bracket(q)}   so x = {-p} or x = {-q}")
    else:
        print(f"{show(1, b, c)}: no whole-number pair, use the formula")
```

**Output**

```text
x^2 - 5x + 6 = (x - 3)(x - 2)   so x = 3 or x = 2
x^2 + x - 12 = (x - 3)(x + 4)   so x = 3 or x = -4
x^2 + 7x + 10 = (x + 2)(x + 5)   so x = -2 or x = -5
x^2 + 2x - 4: no whole-number pair, use the formula
```

Notice the last line. x² + 2x − 4 has no whole-number pair, because its solutions are not whole numbers. Factorising is the fastest method when it works, but it does not always work.

## Method 2: the quadratic formula

The quadratic formula works for every quadratic equation:

> **The quadratic formula**

> For ax² + bx + c = 0: **x = (−b ± √(b² − 4ac)) / 2a**. The ± means you do the calculation twice, once with + and once with −, to get the two solutions.

For x² + 2x − 4 = 0: a = 1, b = 2, c = −4. Then b² − 4ac = 4 + 16 = 20, so x = (−2 ± √20) / 2 = −1 ± √5. That is about 1.236 and -3.236. The formula turned an equation that would not factorise into two exact answers. Here it is in code, handling every case:

**formula.py**

```python
import math

def show(a, b, c):
    """Write ax^2 + bx + c the way you would by hand."""
    s = ("" if a == 1 else str(a)) + "x^2"
    s += f" {'-' if b < 0 else '+'} " + ("" if abs(b) == 1 else str(abs(b))) + "x" if b else ""
    s += f" {'-' if c < 0 else '+'} {abs(c)}" if c else ""
    return s

def solve_quadratic(a, b, c):
    """Real solutions of ax^2 + bx + c = 0."""
    d = b * b - 4 * a * c          # the discriminant
    if d < 0:
        return d, []
    if d == 0:
        return d, [-b / (2 * a)]
    root = math.sqrt(d)
    return d, sorted([(-b - root) / (2 * a), (-b + root) / (2 * a)])

if __name__ == "__main__":
    for a, b, c in [(1, -5, 6), (1, 2, -4), (1, 6, 9), (1, 2, 5)]:
        d, xs = solve_quadratic(a, b, c)
        shown = ", ".join(f"{x:.4g}" for x in xs) or "no real solutions"
        print(f"{show(a, b, c)} = 0".ljust(20), f"discriminant {d:>3}   x = {shown}")
```

**Output**

```text
x^2 - 5x + 6 = 0     discriminant   1   x = 2, 3
x^2 + 2x - 4 = 0     discriminant  20   x = -3.236, 1.236
x^2 + 6x + 9 = 0     discriminant   0   x = -3
x^2 + 2x + 5 = 0     discriminant -16   x = no real solutions
```

## The discriminant: how many solutions?

The part under the square root, b² − 4ac, is called the **discriminant**, and it tells you what to expect before you solve anything:

![Three parabolas: a positive discriminant crosses the x-axis twice for two solutions, zero touches it once for one solution, and negative misses it entirely for no real solutions](/images/blog/how-to-solve-quadratic-equations/01-discriminant.png)

*The discriminant is the sign under the square root.*

- **Positive** (like 1 or 20 above): two different solutions. The parabola crosses the x-axis twice.
- **Zero** (like x² + 6x + 9): exactly one solution, x = −3. The parabola just touches the axis.
- **Negative** (like −16 for x² + 2x + 5): no real solutions, because you cannot take the square root of a negative number with ordinary numbers. The parabola never reaches the axis.

In later maths, negative discriminants lead to complex numbers, but at GCSE and Class 10 level the answer is simply "no real solutions".

## Method 3: completing the square

Completing the square rewrites the equation so that x appears only once, inside a squared bracket. It is also where the quadratic formula comes from. Take x² + 6x + 2 = 0. Picture x² + 6x as a square of side x with two strips of 3 by x attached: it is a bigger square with one corner missing, and that corner is 3 × 3 = 9.

![Completing the square for x squared plus 6x plus 2: x squared plus two strips of 3x form a square with a missing 3 by 3 corner of 9, so x squared plus 6x plus 9 equals (x plus 3) squared, giving (x plus 3) squared equals 7 and x = minus 3 plus or minus root 7](/images/blog/how-to-solve-quadratic-equations/03-square.png)

*Half of b, squared, is the missing corner.*

1. Halve the x coefficient: half of 6 is 3. The missing corner is 3² = 9.
2. Add and subtract it: x² + 6x + 9 − 9 + 2 = 0, which is (x + 3)² − 7 = 0.
3. Rearrange: (x + 3)² = 7, so x + 3 = ±√7.
4. Solve: x = −3 ± √7, about -0.354 or -5.646.

Completing the square is also the easiest way to find the turning point of a parabola: (x + 3)² − 7 has its lowest point at x = −3, y = −7.

## A real example: a ball thrown upwards

Throw a ball straight up at 20 metres per second and its height after t seconds is roughly h = 20t − 5t² (5 is about half of gravity's 9.8, rounded to keep the numbers simple). When is the ball 15 metres high?

**ball.py**

```python
# A ball is thrown up at 20 m/s. Its height after t seconds is roughly h = 20t - 5t^2.
# (Using 5 for half of gravity's 9.8 keeps the numbers simple.)
import math

def times_at_height(h):
    # 20t - 5t^2 = h  becomes  5t^2 - 20t + h = 0
    a, b, c = 5, -20, h
    d = b * b - 4 * a * c
    if d < 0:
        return []
    return sorted({(-b - math.sqrt(d)) / (2 * a), (-b + math.sqrt(d)) / (2 * a)})

for h in (0, 15, 20, 25):
    ts = times_at_height(h)
    print(f"height {h:>2} m: " + (", ".join(f"t = {t:g} s" for t in ts) if ts else "never reached"))
```

**Output**

```text
height  0 m: t = 0 s, t = 4 s
height 15 m: t = 1 s, t = 3 s
height 20 m: t = 2 s
height 25 m: never reached
```

![Height of a ball thrown up at 20 metres per second: it passes 15 metres at 1 second going up and 3 seconds coming down, peaks at 20 metres at 2 seconds and lands at 4 seconds](/images/blog/how-to-solve-quadratic-equations/04-ball.png)

*Two solutions, and both of them are real moments in the flight.*

Both answers make sense: the ball passes 15 m at 1 second on the way up and at 3 seconds on the way down. It reaches 20 m exactly once, at the top (a zero discriminant), and never reaches 25 m (a negative one). The three cases of the discriminant are three real situations.

## Which method should you use?

| Situation | Best method |
| --- | --- |
| Small whole numbers, and a pair jumps out | Factorising |
| Anything else, or the question says "to 2 decimal places" | The quadratic formula |
| The question asks for the turning point or "the form (x + p)² + q" | Completing the square |
| Checking an answer | Substitute it back into the original equation |

> **Always check**

> Put each solution back into the original equation. For x = 3 in x² − 5x + 6: 9 − 15 + 6 = 0. It takes seconds and catches sign mistakes, which are the most common error in this topic. If negatives cause trouble, our guide to [negative numbers](/blog/negative-numbers-explained) helps.

> Two answers are not a complication. A parabola can cross a line twice, and a ball can be at the same height twice.

## How we teach it

Quadratics suit two principles on our [how we teach](/how-we-teach) page. We show the same problem three ways until the aha lands, and quadratics come with exactly three methods. And students derive the rule themselves before they ever see it written down: completing the square on a general quadratic is how the formula appears, rather than being handed over to memorise. Our [GCSE maths tuition](/gcse-maths-tuition-online) runs one to one or in small groups of 5 to 10.

[Book a free class](/book-demo) [Book a priority demo](/book-demo)

## Frequently asked questions

**How do you solve a quadratic equation?**

Rearrange it to ax squared plus bx plus c = 0, then factorise it, use the quadratic formula, or complete the square. Factorising is quickest when it works; the formula always works; completing the square also gives the turning point.

**What is the quadratic formula?**

x = (minus b plus or minus the square root of (b squared minus 4ac)) divided by 2a. It solves any quadratic equation ax squared plus bx plus c = 0 and gives both solutions at once.

**What does the discriminant tell you?**

The discriminant b squared minus 4ac tells you how many real solutions there are: two if it is positive, one if it is zero, and none if it is negative.

**Why do quadratic equations have two solutions?**

Because a parabola can cross the x-axis in two places. In real problems both often make sense, like a ball passing the same height once going up and once coming down.

**How do you know if a quadratic can be factorised?**

For whole-number coefficients, it factorises neatly when the discriminant is a perfect square, such as 1, 4 or 9. Otherwise, use the formula.

**What is completing the square used for?**

It solves quadratic equations, finds the turning point of a parabola, and is how the quadratic formula is derived. It is required in GCSE Higher and many other syllabuses.

**Can a quadratic equation have no solution?**

It can have no real solutions, when the discriminant is negative and the parabola never touches the x-axis. In advanced maths these equations have complex solutions.

---

*Source: https://learn.modernagecoders.com/blog/how-to-solve-quadratic-equations/*
