Skip to content
EN - Language: English
MathematicsHigh school

Special products - perfect squares and the difference of two squares, step by step

· 15 min read

In short

(a + b)² = a² + 2ab + b², (a − b)² = a² − 2ab + b² and a² − b² = (a + b)(a − b). A square of side a + b is made of a square a², a square b² and two rectangles a by b - those two rectangles are the 2ab that is easy to forget. Read from left to right, the formulas expand brackets; read backwards, they factorise expressions such as x² − 6x + 9 = (x − 3)².

Words to know

Perfect square
An expression that is something squared, such as x² − 6x + 9 = (x − 3)².
Difference of two squares
An expression a² − b². It factorises as (a + b)(a − b).
Middle term
The 2ab in a² + 2ab + b² - twice the product of a and b.
Expanding brackets
Multiplying out a product, so that it becomes a sum of terms.
Factorising
Writing a sum as a product - expanding brackets in reverse.

What do you think?

A square garden has sides of 5 m. Each side is made 2 m longer. By how much does the area of the garden grow?

The idea: the square of a sum is more than the sum of the squares

Take a square with side a+ba + b. Its area is (a+b)2(a + b)^2. Cut each side into a piece aa and a piece bb, and the square falls apart into four pieces:

  • a square a2a^2,
  • a square b2b^2,
  • two rectangles aa by bb, with area abab each.

So (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2. The two rectangles, 2ab2ab, are the part that is easy to forget. The same kind of picture explains two more formulas: the square of a difference, (a−b)2=a2−2ab+b2(a - b)^2 = a^2 - 2ab + b^2, and the difference of two squares, a2−b2=(a+b)(a−b)a^2 - b^2 = (a + b)(a - b). Together they are called special products.

Three formulas from one square, step by step

The picture is made of small squares, so you can count every area. Here a=5a = 5 and b=2b = 2. Go through the animation with the buttons or the arrow keys.

(a + b)²49abab

(a + b)² = (5 + 2)² = 7² = 49

Step 1 of 7
Steps of the animation. Arrow keys move between steps.

A square with side a + b - here 5 + 2 = 7. It is made of 7 · 7 = 49 small squares, so (a + b)² = 49.

The pictures need lengths, so aa and bb are positive there, and a>ba > b when we cut bb off aa. The formulas themselves hold for any numbers, negative ones and fractions included. You can check that by multiplying out the brackets - it is done in “The definitions” below.

Try it yourself: change a and b

Set the lengths aa and bb and choose a formula. The picture cuts the squares in the same way as the animation. The readouts give both sides of the formula with numbers, next to the mistake that is easy to make with it.

a²25ab10ab10b²4abab
Formula
a = 5
b = 2
square of a sum
(5 + 2)² = 7² = 49
a² + 2ab + b²
25 + 20 + 4 = 49
wrong: a² + b²
25 + 4 = 29 ≠ 49

What to notice:

  • both sides of each formula always give the same number,
  • the mistake a2+b2a^2 + b^2 always falls short of (a+b)2(a + b)^2 by exactly the two rectangles, 2ab2ab,
  • (a−b)2(a - b)^2 and a2−b2a^2 - b^2 are different numbers. They are equal only when b=0b = 0 or a=ba = b,
  • when bb is larger than aa, the picture cannot cut bb off aa, but the formulas still work: (2−5)2=(−3)2=9(2 - 5)^2 = (-3)^2 = 9, the same as (5−2)2(5 - 2)^2, because (a−b)2=(b−a)2(a - b)^2 = (b - a)^2.

The definitions

Special products are formulas for multiplying out brackets quickly. For any numbers aa and bb:

(a+b)2=a2+2ab+b2(a−b)2=a2−2ab+b2a2−b2=(a+b)(a−b)\begin{aligned} (a + b)^2 &= a^2 + 2ab + b^2 \\ (a - b)^2 &= a^2 - 2ab + b^2 \\ a^2 - b^2 &= (a + b)(a - b) \end{aligned}

The first two are the square of a sum and the square of a difference. Their results are perfect squares (in the US also called perfect square trinomials). The third formula is the difference of two squares.

You do not have to take the formulas on trust. Multiply each term of the first bracket by each term of the second, and collect like terms:

(a+b)2=(a+b)(a+b)=a2+ab+ba+b2=a2+2ab+b2\begin{aligned} (a + b)^2 &= (a + b)(a + b) \\ &= a^2 + ab + ba + b^2 \\ &= a^2 + 2ab + b^2 \end{aligned}

In the same way, (a+b)(a−b)=a2−ab+ba−b2(a + b)(a - b) = a^2 - ab + ba - b^2, and the two middle terms cancel, leaving a2−b2a^2 - b^2.

In place of aa and bb you can put any numbers and any expressions, such as 3x3x, 2\sqrt{2} or x2x^2. Read from left to right, the formulas expand brackets. Read from right to left, they factorise: they turn a sum into a product, as in x2−6x+9=(x−3)2x^2 - 6x + 9 = (x - 3)^2. A sum of two squares, such as x2+9x^2 + 9, has no such formula. It cannot be written as a product of brackets with real numbers.

The formulas also help with mental arithmetic:

512=(50+1)2=2500+100+1=2601\begin{aligned} 51^2 &= (50 + 1)^2 \\ &= 2500 + 100 + 1 \\ &= 2601 \end{aligned}
49⋅51=(50−1)(50+1)=2500−1=2499\begin{aligned} 49 \cdot 51 &= (50 - 1)(50 + 1) \\ &= 2500 - 1 \\ &= 2499 \end{aligned}

For cubes there are formulas too. The sum and the difference of two cubes also factorise:

(a+b)3=a3+3a2b+3ab2+b3(a−b)3=a3−3a2b+3ab2−b3\begin{aligned} (a + b)^3 &= a^3 + 3a^2b \\ &\quad + 3ab^2 + b^3 \\ (a - b)^3 &= a^3 - 3a^2b \\ &\quad + 3ab^2 - b^3 \end{aligned}
a3+b3=(a+b)(a2−ab+b2)a3−b3=(a−b)(a2+ab+b2)\begin{aligned} a^3 + b^3 &= (a + b)(a^2 - ab + b^2) \\ a^3 - b^3 &= (a - b)(a^2 + ab + b^2) \end{aligned}

For example, 113=(10+1)3=1000+300+30+1=133111^3 = (10 + 1)^3 = 1000 + 300 + 30 + 1 = 1331.

Example 1: expanding the square of a difference

Expand (3x−2)2(3x - 2)^2.

Step 1. Spot the formula

This is the square of a difference, (a−b)2=a2−2ab+b2(a - b)^2 = a^2 - 2ab + b^2, with these two terms:

a=3xb=2\begin{aligned} a &= 3x \\ b &= 2 \end{aligned}

Step 2. Work out the three terms

We square aa, double the product abab and square bb, one at a time.

a2=(3x)2=9x22ab=2⋅3x⋅2=12xb2=22=4\begin{aligned} a^2 &= (3x)^2 = 9x^2 \\ 2ab &= 2 \cdot 3x \cdot 2 = 12x \\ b^2 &= 2^2 = 4 \end{aligned}

Step 3. Put them into the formula

The middle term has a minus sign, and the last term is positive.

(3x−2)2=9x2−12x+4(3x - 2)^2 = \boxed{9x^2 - 12x + 4}

Answer

(3x−2)2=9x2−12x+4(3x - 2)^2 = 9x^2 - 12x + 4. Three terms, and the middle one, −12x-12x, comes from the two rectangles of the picture.

Example 2: factorising with the formulas read backwards

Factorise 4x2−94x^2 - 9 and x2−6x+9x^2 - 6x + 9.

Step 1. Write the first expression as a difference of squares

Both terms of 4x2−94x^2 - 9 are squares: 4x24x^2 is 2x2x squared, and 99 is 33 squared.

4x2−9=(2x)2−324x^2 - 9 = (2x)^2 - 3^2

Step 2. Use the difference of two squares

With a=2xa = 2x and b=3b = 3, the formula a2−b2=(a+b)(a−b)a^2 - b^2 = (a + b)(a - b) gives the factors.

4x2−9=(2x+3)(2x−3)4x^2 - 9 = \boxed{(2x + 3)(2x - 3)}

Step 3. Check the middle term of the second expression

In x2−6x+9x^2 - 6x + 9 the first and last terms are squares, x2x^2 and 323^2. A perfect square needs a middle term of 2ab2ab.

2⋅x⋅3=6x2 \cdot x \cdot 3 = 6x

Step 4. Write it as a square

The middle term is 6x6x with a minus sign, so it is the square of a difference.

x2−6x+9=(x−3)2x^2 - 6x + 9 = \boxed{(x - 3)^2}

Answer

4x2−9=(2x+3)(2x−3)4x^2 - 9 = (2x + 3)(2x - 3) and x2−6x+9=(x−3)2x^2 - 6x + 9 = (x - 3)^2. Expanding the brackets again gives back the expressions we started from.

Your turn

Simplify (2x+3)2−(2x−3)2(2x + 3)^2 - (2x - 3)^2.

Hintshow

Expand both squares first. Then remember that the minus sign in front of the second bracket changes the sign of every term inside it. For a check, you can also see the whole expression as a difference of two squares.

Solutiontry it on your own first

Step 1. Expand the square of the sum

We use (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2 with a=2xa = 2x and b=3b = 3.

(2x+3)2=4x2+12x+9(2x + 3)^2 = 4x^2 + 12x + 9

Step 2. Expand the square of the difference

The same terms, but now the middle one is subtracted.

(2x−3)2=4x2−12x+9(2x - 3)^2 = 4x^2 - 12x + 9

Step 3. Remove the brackets

The minus sign in front of the second bracket changes the sign of each of its three terms.

4x2+12x+9−4x2+12x−9\begin{aligned} &4x^2 + 12x + 9 \\ &- 4x^2 + 12x - 9 \end{aligned}

Step 4. Collect like terms

4x24x^2 and −4x2-4x^2 cancel, and so do 99 and −9-9.

12x+12x=24x12x + 12x = \boxed{24x}

Step 5. Check with the difference of two squares

The whole expression is a2−b2a^2 - b^2 with a=2x+3a = 2x + 3 and b=2x−3b = 2x - 3, so we work out a+ba + b and a−ba - b.

a+b=4xa−b=6(a+b)(a−b)=24x\begin{aligned} a + b &= 4x \\ a - b &= 6 \\ (a + b)(a - b) &= 24x \end{aligned}

Answer

(2x+3)2−(2x−3)2=24x(2x + 3)^2 - (2x - 3)^2 = 24x. At x=1x = 1 this gives 52−(−1)2=25−1=245^2 - (-1)^2 = 25 - 1 = 24, as it should.

Common mistakes

  • (a+b)2(a + b)^2 written as a2+b2a^2 + b^2. The two rectangles 2ab2ab go missing: (5+2)2=49(5 + 2)^2 = 49, but 52+22=295^2 + 2^2 = 29. The two are equal only when a=0a = 0 or b=0b = 0.
  • (a−b)2(a - b)^2 written as a2−b2a^2 - b^2. These are different formulas: (5−2)2=9(5 - 2)^2 = 9, but 52−22=215^2 - 2^2 = 21.
  • Squaring only part of a term. (3x)2=9x2(3x)^2 = 9x^2, not 3x23x^2.
  • A minus sign on the last term. (x−3)2=x2−6x+9(x - 3)^2 = x^2 - 6x + 9, not x2−6x−9x^2 - 6x - 9. The last term is the square b2b^2, and a square is never negative.
  • A sum of squares “factorised”. x2+9x^2 + 9 is not (x+3)2(x + 3)^2, which equals x2+6x+9x^2 + 6x + 9.

At GCSE, A-level and in the US

In England, expanding products of two brackets and factorising quadratic expressions of the form x2+bx+cx^2 + bx + c, including the difference of two squares, are part of GCSE Mathematics. GCSE also asks you to show that two algebraic expressions are equivalent - exactly what multiplying out the brackets does in “The definitions”.

A-level Mathematics builds on the same algebra. Completing the square uses a perfect square backwards, as in the vertex form of a quadratic function. Rationalising a denominator with a surd uses the difference of two squares: (3+2)(3−2)=9−2=7(3 + \sqrt{2})(3 - \sqrt{2}) = 9 - 2 = 7, a whole number. The binomial expansion of (a+bx)n(a + bx)^n continues the pattern of (a+b)2(a + b)^2 and (a+b)3(a + b)^3 to higher powers.

In the US, the Common Core standards for high-school algebra give an example of the same idea: see x4−y4x^4 - y^4 as (x2)2−(y2)2(x^2)^2 - (y^2)^2, a difference of squares that factors as (x2−y2)(x2+y2)(x^2 - y^2)(x^2 + y^2).

Check yourself

Test yourself

What is (x+5)2(x + 5)^2?

Which expression equals 4x2−12x+94x^2 - 12x + 9?

What is 31⋅2931 \cdot 29?

Which expression cannot be factorised with these formulas?

A square with side a+ba + b is cut into two squares and two rectangles. What is the area of the two rectangles together?

Flashcards for review

Flip a card and say whether you knew the answer. The ones you did not know come back at the end of the deck. Why it pays to come back to them in a few days is explained in the guide Spaced repetition.

Flashcards

  1. What is (a+b)2(a + b)^2?

    a2+2ab+b2a^2 + 2ab + b^2 - the square of a sum.
  2. What is (a−b)2(a - b)^2?

    a2−2ab+b2a^2 - 2ab + b^2 - the square of a difference. The last term, b2b^2, is positive.
  3. What is a2−b2a^2 - b^2 as a product?

    (a+b)(a−b)(a + b)(a - b) - the difference of two squares.
  4. Where does the 2ab2ab in (a+b)2(a + b)^2 come from in the picture?

    From the two rectangles aa by bb in a square of side a+ba + b. The other two pieces are the squares a2a^2 and b2b^2.
  5. Why is there +b2+b^2 in (a−b)2(a - b)^2?

    When two strips aa by bb are cut off the square a2a^2, the corner b2b^2 lies in both of them, so it is cut off twice. It has to be added back once.
  6. When is (a+b)2(a + b)^2 equal to a2+b2a^2 + b^2?

    Only when a=0a = 0 or b=0b = 0 - when 2ab=02ab = 0.
  7. How do you check that x2−6x+9x^2 - 6x + 9 is a perfect square?

    x2x^2 and 9=329 = 3^2 are squares, and the middle term is 2⋅x⋅3=6x2 \cdot x \cdot 3 = 6x. So x2−6x+9=(x−3)2x^2 - 6x + 9 = (x - 3)^2.
  8. Can x2+9x^2 + 9 be factorised with these formulas?

    No. It is a sum of two squares, and it cannot be written as a product of brackets with real numbers.
  9. What is (3x)2(3x)^2?

    9x29x^2 - the square applies to the 3 as well as to the xx.
  10. What is a3−b3a^3 - b^3 as a product?

    (a−b)(a2+ab+b2)(a - b)(a^2 + ab + b^2) - the difference of two cubes.

Sources

We checked the facts on this page against these sources. All of them may be reused freely: they carry an open licence or are not covered by copyright.

  1. Illustrative Mathematics - Algebra 1, Unit 7, Lesson 6: Rewriting Quadratic Expressions in Factored Form, Part 1 (an area diagram keeps track of every product when you multiply out two brackets) · CC BY 4.0
  2. Illustrative Mathematics - Algebra 1, Unit 7, Lesson 8: Rewriting Quadratic Expressions in Factored Form, Part 3 (the difference of two squares a² − b² = (a + b)(a − b); is (x + 4)² equal to x² + 4²; x² + 9 does not factorise; squaring a two-digit number in your head) · CC BY 4.0
  3. Illustrative Mathematics - Algebra 1, Unit 7, Lesson 11: What are Perfect Squares? ((x + n)² = x² + 2nx + n²; a perfect square is an expression that is something times itself) · CC BY 4.0
  4. LibreTexts - Corequisite Companion to Precalculus (Freidenreich), 1.2 FOIL Method and Special Products (multiplying out brackets as the area of a rectangle; perfect square trinomials and the difference of squares) · CC BY-SA 4.0
  5. LibreTexts - Corequisite Companion to Precalculus (Freidenreich), 2.3 Review of Factoring ((A ± B)² = (A ± B)(A ± B) = A² ± 2AB + B², the difference of squares, the sum and difference of cubes; a sum of squares does not factorise) · CC BY-SA 4.0
  6. Wikibooks - A-Level Maths & Further Maths/Algebraic Expressions (expanding brackets; writing (x + y)² as x² + y² is a common mistake; the difference of two squares) · CC BY-SA 4.0
  7. Wikipedia - Difference of two squares (the proof by multiplying out; a square with a corner cut out, rearranged into a rectangle (a + b) by (a − b); mental arithmetic) · CC BY-SA 4.0
  8. Wikipedia - Binomial theorem (a square of side a + b cut into a square a², a square b² and two rectangles; (x + y)³ = x³ + 3x²y + 3xy² + y³) · CC BY-SA 4.0

More explainers