Monocurl Essays
Series Download

The distributive law as a picture: FOIL and (a+b)²

Cutting a rectangle into pieces explains FOIL, why (a+b)² has a middle term 2ab, and why (a+b)(a−b) = a² − b². Each identity is then proved.

22 min·Middle and high school·

AssumesWhy is a negative times a negative positive?

A 13 by 13 square of unit cells comes apart into a 10 by 10 square, a 3 by 3 square and two 10 by 3 strips. The strips hold the 60 cells that $10^2 + 3^2$ leaves out: $100 + 60 + 9 = 169$.
Monocurl source
let a = 10
let b = 3
let P = [-3.45, -1.5, 0]
let COLS = [AZURE, LEAF, LEAF, EMBER]
mesh fig = Four(P, a, b, a, b, 0.25, gap: 0, 2, COLS, 1)
mesh sums = []

slide "apart"
    play Wait(0.8)
    fig.gap = 0.2
    play Lerp(1.6, [&fig])
    fig = Four(P, a, b, a, b, 0.25, gap: 0.2, 2, COLS, 2)
    sums = Column(
        [
            str_join([to_string(a), "^2 = ", to_string(a * a)]),
            str_join(["2 \times ", to_string(a * b), " = ", to_string(2 * a * b)]),
            str_join([to_string(b), "^2 = ", to_string(b * b)])
        ],
        [AZURE, LEAF, EMBER],
        str_join([to_string(a + b), "^2 = ", to_string((a + b) * (a + b))]),
        2.1, 1.2
    )
    play Fade(0.9)
    play Wait(2.2)

Uses the shared definitions for this lesson's figures.

A student asked to square 13 reasons as follows: 13 is $10 + 3$, the square of 10 is 100, the square of 3 is 9, so the answer is 109. The method feels sound, because it is exactly how the same student would double 13 (double the 10, double the 3, add). But $13 \times 13$ is 169. Sixty has gone missing, and the student’s rule gives no hint about where.

The answer to “where did the 60 go” is in the animation above, and by the end of this lesson you will be able to read it off at a glance. Getting there requires only one law of arithmetic, the one that tells you how multiplication and addition interact. We will draw that law as a rectangle, and then use the same drawing to explain three results that are usually memorized separately: the FOIL rule for multiplying two brackets, the formula for $(a+b)^2$, and the difference of squares.

One rectangle, cut in two

Start with a multiplication that is slightly too big to know by heart, $4 \times 13$. Most people who do it in their head split the 13: four tens are 40, four threes are 12, and together that makes 52. The figure shows why splitting is allowed. A rectangle that is 4 cells tall and 13 cells wide contains $4 \times 13$ cells. Cut it with a vertical line after the tenth column. No cell is created or destroyed by the cut, so the two pieces together contain the same number of cells as before.

A 4 by 13 rectangle is cut after its tenth column into a 4 by 10 piece and a 4 by 3 piece. The pieces hold 40 and 12 cells, so $4 \times 13 = 4 \times 10 + 4 \times 3 = 52$.
Monocurl source
let G = 0.45
let X0 = -2.95
let Y0 = -0.3
mesh left = Block([X0, Y0, 0], 10, 4, G, AZURE)
mesh right = Block(p: [X0 + 10 * G, Y0, 0], 3, 4, G, col: AZURE)
mesh side = center{[X0 - 0.36, Y0 + 2 * G, 0]} Math("4", 0.85)
mesh labels = center{[X0 + 6.5 * G, Y0 - 0.36, 0]} Math("13", 0.85)
mesh line = []

slide "cut"
    play Wait(0.8)
    labels = []
    play Fade(0.3, [&labels])
    right.p = [X0 + 10 * G + 0.3, Y0, 0]
    right.col = EMBER
    play Lerp(1.4, [&right])
    labels = [
        center{[X0 + 5 * G, Y0 - 0.36, 0]} Math("10", 0.85, AZURE),
        center{[X0 + 11.5 * G + 0.3, Y0 - 0.36, 0]} Math("3", 0.85, EMBER),
        Tagged([X0 + 5 * G, Y0 + 2 * G, 0], to_string(4 * 10), AZURE, 0.6, 0.9),
        Tagged([X0 + 11.5 * G + 0.3, Y0 + 2 * G, 0], to_string(4 * 3), EMBER, 0.6, 0.9)
    ]
    play Fade(0.6, [&labels])
    line = center{[0, -1.55, 0]} Math(
        str_join(["4 \times 13 = 4 \times 10 + 4 \times 3 = ", to_string(4 * 13)]), 0.92)
    play Fade(0.6, [&line])
    play Wait(2)

Uses the shared definitions for this lesson's figures.

Written as an equation, the cut says

$$ 4 \times (10 + 3) = 4 \times 10 + 4 \times 3. $$

Nothing in the picture depended on the particular numbers. A rectangle with height $a$ and width $b + c$ can always be cut into one piece of width $b$ and one of width $c$, and the areas of the pieces add up to the area of the whole.

Pause and try

Use one cut to work out $7 \times 23$ in your head. Say which rectangle you are cutting and where.

Show answerHide answer

Take a rectangle 7 tall and 23 wide and cut it after the twentieth column. The pieces are 7 by 20 and 7 by 3, with areas 140 and 21, so $7 \times 23 = 161$.

The distributive law, stated exactly

The fact we have been using has a name.

It is worth being clear about what the rectangle does and does not establish, because the law is stated for all real numbers and a rectangle cannot have a side of length $-3$.

When $a$, $b$ and $c$ are positive whole numbers, the picture is a complete proof: a grid with $a$ rows and $b + c$ columns is literally made of a grid with $a$ rows and $b$ columns next to one with $a$ rows and $c$ columns, and counting cells gives the law. When they are positive lengths that are not whole numbers, the picture says that area is unchanged by cutting, which is part of what we mean by area. For negative numbers no picture is available, and the law is instead one of the basic rules that negative numbers are required to obey. The previous lesson, why a negative times a negative is positive, showed that requiring it forces the sign rules, including $a \times (-b) = -(ab)$ and $(-a)(-b) = ab$, which we will use below.

So from here on we treat the distributive law as given for all real numbers. Everything else below is proved from it, together with the fact that the order of a product does not matter ($ab = ba$). The pictures will show why each result is true for positive lengths, and a short calculation will then show that it is true for all numbers.

One immediate consequence is that the sum can also sit on the left. Since $(b + c)a = a(b + c)$ by swapping the order, we get

$$ (b + c)a = ba + ca. $$

Two cuts: the product of two sums

Now take a product where both numbers are awkward, $13 \times 12$. One cut is not enough to make it easy, since $13 \times 12 = 10 \times 12 + 3 \times 12$ still leaves two products to work out. But nothing stops us from cutting the other way as well.

Pause and try

Before stepping through the figure, split $13$ as $10 + 3$ and $12$ as $10 + 2$. Into how many pieces do the two cuts divide the rectangle, and what are their areas? Add them to get $13 \times 12$.

Show answerHide answer

There are four pieces: $10 \times 10 = 100$, $10 \times 2 = 20$, $3 \times 10 = 30$ and $3 \times 2 = 6$. Their total is $156$, so $13 \times 12 = 156$.

  1. A rectangle 13 cells wide and 12 cells tall holds 13 x 12 cells.
  2. Cut the width into 10 + 3. The two pieces hold 120 and 36 cells.
  3. Cut the height into 10 + 2 as well. Four pieces: 100, 30, 20 and 6, which add to 156.
The product $13 \times 12$ as a rectangle of unit cells, cut once into $120 + 36$ and then again into four pieces, $100 + 30 + 20 + 6 = 156$. Each piece is one part of 13 times one part of 12.
Monocurl source
let P = [-3.2, -1.55, 0]
let G = 0.27
let COLS = [AZURE, GOLD, PLUM, EMBER]
mesh fig = []
mesh sums = []

slide "A rectangle 13 cells wide and 12 cells tall holds 13 x 12 cells."
    fig = [Four(P, 10, 3, 10, 2, G, 0, 0, COLS, 1), Tagged([P[0] + 6.5 * G, P[1] + 6 * G, 0], "13 \times 12", AZURE, 1.5, 0.9)]
    play Fade(0.8)

slide "Cut the width into 10 + 3. The two pieces hold 120 and 36 cells."
    fig = Four(P, 10, 3, 10, 2, G, 0.14, 1, COLS, 2)
    sums = Column([eq(10, 12), eq(3, 12)], [AZURE, EMBER], to_string(10 * 12 + 3 * 12), 2.3, 1.0)
    play Fade(0.8)

slide "Cut the height into 10 + 2 as well. Four pieces: 100, 30, 20 and 6, which add to 156."
    sums = []
    play Fade(0.3, [&sums])
    fig = Four(P, 10, 3, 10, 2, G, 0.14, 2, COLS, 2)
    sums = Column([eq(10, 10), eq(10, 2), eq(3, 10), eq(3, 2)], [AZURE, PLUM, GOLD, EMBER], to_string(13 * 12), 2.3, 1.4, LEAF)
    play Fade(0.8)

Uses the shared definitions for this lesson's figures.

Each of the four pieces is one part of 13 multiplied by one part of 12, and every such pairing appears exactly once. In letters, a rectangle with sides $a + b$ and $c + d$ is cut into pieces of area $ac$, $ad$, $bc$ and $bd$.

The proof follows the two cuts exactly, but it never mentions lengths, so it holds whether the numbers are positive, negative or zero.

Many people learn this theorem under the name FOIL, which stands for First, Outer, Inner, Last: multiply the first terms of the two brackets ($ac$), the outer terms ($ad$), the inner terms ($bc$) and the last terms ($bd$). The word is a way of making sure all four pieces of the rectangle are accounted for. The same idea works when the brackets have more terms. If one side is cut into three parts and the other into two, there are six pieces, and in general every term of the first bracket multiplies every term of the second.

The product 23 \times 114 by the box method, not drawn to scale. Each box is one part of 23 times one part of 114. The two rows add to 2280 and 342, the same two lines that appear in long multiplication, and together they make 2622.
The product $23 \times 114$ by the box method, not drawn to scale. Each box is one part of 23 times one part of 114. The two rows add to 2280 and 342, the same two lines that appear in long multiplication, and together they make 2622.
Monocurl source
let xs = [100, 10, 4]
let ys = [20, 3]
let ws = [2.5, 1.5, 1.05]
let hs = [1.45, 0.95]
let LEFT_X = -3.0
let TOP_Y = 1.45
let row_cols = [AZURE, EMBER]
mesh boxes = block {
    var y = TOP_Y
    for (j in range(0, 2)) {
        var x = LEFT_X
        var total = 0
        for (i in range(0, 3)) {
            let pos = [x + ws[i] / 2, y - hs[j] / 2, 0]
            . Box(pos, [ws[i], hs[j]], row_cols[j], 0.2)
            . center{pos} Math(to_string(xs[i] * ys[j]), 0.85, row_cols[j])
            total = total + xs[i] * ys[j]
            x = x + ws[i]
        }
        . center{[LEFT_X - 0.4, y - hs[j] / 2, 0]} Math(to_string(ys[j]), 0.85)
        . center{[x + 0.75, y - hs[j] / 2, 0]} Math(str_join(["= ", to_string(total)]), 0.85, row_cols[j])
        y = y - hs[j]
    }
    var x = LEFT_X
    for (i in range(0, 3)) {
        . center{[x + ws[i] / 2, TOP_Y + 0.33, 0]} Math(to_string(xs[i]), 0.85)
        x = x + ws[i]
    }
}
mesh line = center{[-0.3, -1.6, 0]} Math(
    str_join(["23 \times 114 = ", to_string(20 * 114), " + ", to_string(3 * 114), " = ", to_string(23 * 114)]), 0.9)

Uses the shared definitions for this lesson's figures.

This is what long multiplication does. Each line of a long multiplication is one row of the box, and the place-value columns keep track of the cuts.

The square of a sum

We can now return to the student who squared 13 and got 109. Squaring 13 means finding the area of a 13 by 13 square. Splitting 13 as $10 + 3$ cuts both sides of the square, so by the theorem there should be four pieces. The student’s answer, $10^2 + 3^2$, accounts for two of them.

Pause and try

Draw a 13 by 13 square and cut each side into 10 and 3. Shade the $10 \times 10$ and $3 \times 3$ pieces. What are the shapes and areas of the parts left unshaded?

Show answerHide answer

Two rectangles are left unshaded, each 10 by 3, so each has area 30. Together they hold the 60 cells that $100 + 9$ leaves out.

  1. A 13 by 13 square holds 13 x 13 = 169 cells.
  2. Squaring the 10 and the 3 separately covers only these two squares: 100 + 9 = 109.
  3. The two red strips were left out. Each is 10 by 3, which is 30 cells.
  4. Counting the strips as well gives 100 + 30 + 30 + 9 = 169.
The square of 13 as a 13 by 13 grid. The squares of 10 and of 3 cover only part of it, and the two uncovered strips are each 10 by 3. Counting them gives $13^2 = 100 + 2 \times 30 + 9 = 169$.
Monocurl source
let a = 10
let b = 3
let P = [-3.3, -1.55, 0]
let G = 0.26
# an area label at cell coordinates (i, j) of the square
let Area = |i, j, v, col| Tagged([P[0] + i * G, P[1] + j * G, 0], to_string(v), col, plate_w(v))
mesh fig = []
mesh areas = []
mesh strips = []
mesh sums = []

slide "A 13 by 13 square holds 13 x 13 = 169 cells."
    fig = [Four(P, a, b, a, b, G, 0, 0, [AZURE, AZURE, AZURE, AZURE], 1), Tagged([P[0] + 6.5 * G, P[1] + 6.5 * G, 0], eq(a + b, a + b), AZURE, 2.3, 0.9)]
    play Fade(0.8)

slide "Squaring the 10 and the 3 separately covers only these two squares: 100 + 9 = 109."
    fig = Four(P, a, b, a, b, G, 0, 2, [AZURE, ROSE, ROSE, EMBER], 1)
    areas = [Area(a / 2, a / 2, a * a, AZURE), Area(a + b / 2, a + b / 2, b * b, EMBER)]
    sums = Column(
        [str_join([to_string(a), "^2 = ", to_string(a * a)]), str_join([to_string(b), "^2 = ", to_string(b * b)])],
        [AZURE, EMBER], to_string(a * a + b * b), 2.2, 1.0, ROSE)
    play Fade(0.8)

slide "The two red strips were left out. Each is 10 by 3, which is 30 cells."
    strips = [Area(a + b / 2, a / 2, a * b, ROSE), Area(a / 2, a + b / 2, a * b, ROSE)]
    play Fade(0.8, [&strips])

slide "Counting the strips as well gives 100 + 30 + 30 + 9 = 169."
    sums = []
    strips = []
    play Fade(0.3, [&sums, &strips])
    fig = Four(P, a, b, a, b, G, 0, 2, [AZURE, LEAF, LEAF, EMBER], 1)
    play Fade(0.6, [&fig])
    strips = [Area(a + b / 2, a / 2, a * b, LEAF), Area(a / 2, a + b / 2, a * b, LEAF)]
    sums = Column(
        [
            str_join([to_string(a), "^2 = ", to_string(a * a)]),
            str_join(["2 \times ", to_string(a * b), " = ", to_string(2 * a * b)]),
            str_join([to_string(b), "^2 = ", to_string(b * b)])
        ],
        [AZURE, LEAF, EMBER], to_string((a + b) * (a + b)), 2.2, 1.2, LEAF)
    play Fade(0.8, [&strips, &sums])

Uses the shared definitions for this lesson's figures.

So the missing 60 is two strips, each with one side from the 10 and one side from the 3. The student’s rule works for doubling because doubling stretches a length, and each part of the length can be stretched separately. Squaring builds an area, and an area built on a side of $10 + 3$ contains regions where the 10 part of one side meets the 3 part of the other.

In the picture, $a^2$ and $b^2$ are the two squares and $2ab$ is the pair of strips. The term $2ab$ is called the cross term, because each strip comes from crossing a part of one side with the other part of the other side.

The next figure keeps $a$ at 10 and lets $b$ vary, so you can watch how much the wrong formula $a^2 + b^2$ misses. The gap is always the two strips, $2ab$.

A square of side $a + b$ with $a = 10$ fixed and $b$ varying from 3 to 5. The two green strips have total area $2ab$, which is exactly the amount by which $(a+b)^2$ exceeds $a^2 + b^2$.
Monocurl source
let S = 0.235
let A = 10
let X0 = -3.55
let Y0 = -1.55
let Sq = |b| {
    let a = A * S
    let w = b * S
    return [
        Box([X0 + a / 2, Y0 + a / 2, 0], [a, a], AZURE, 0.22),
        Box([X0 + a + w / 2, Y0 + a / 2, 0], [w, a], LEAF, 0.3),
        Box([X0 + a / 2, Y0 + a + w / 2, 0], [a, w], LEAF, 0.3),
        Box([X0 + a + w / 2, Y0 + a + w / 2, 0], [w, w], EMBER, 0.3),
        center{[X0 + a / 2, Y0 + a / 2, 0]} Math("a^2", 0.9, AZURE),
        center{[X0 + a + w / 2, Y0 + a / 2, 0]} Math("ab", 0.78, LEAF),
        center{[X0 + a / 2, Y0 + a + w / 2, 0]} Math("ab", 0.78, LEAF),
        center{[X0 + a + w / 2, Y0 + a + w / 2, 0]} Math("b^2", 0.74, EMBER),
        center{[X0 + a + w / 2, Y0 - 0.33, 0]} Math("b", 0.85, EMBER),
        center{[2.9, 1.25, 0]} scale{1.15} color{EMBER} Number(b, 1),
        center{[2.9, 0.5, 0]} scale{1.15} color{INK} Number(A * A + b * b, 1),
        center{[2.9, -0.25, 0]} scale{1.15} color{LEAF} Number(2 * A * b, 1),
        center{[2.9, -1.25, 0]} scale{1.25} color{INK} Number((A + b) * (A + b), 1)
    ]
}
mesh names = [
    center{[X0 + A * S / 2, Y0 - 0.33, 0]} Math("a = 10", 0.85, AZURE),
    center{[1.55, 1.25, 0]} Math("b", 0.9, EMBER),
    center{[1.55, 0.5, 0]} Math("a^2 + b^2", 0.85),
    center{[1.55, -0.25, 0]} Math("2ab", 0.9, LEAF),
    Seg([0.8, -0.72, 0], [3.55, -0.72, 0], SLATE, 2),
    center{[1.55, -1.25, 0]} Math("(a+b)^2", 0.9)
]
mesh sq = Sq(b: 3)

slide "vary b"
    play Wait(0.8)
    sq.b = 5
    play Lerp(3, [&sq])
    play Wait(1.2)
    sq.b = 3
    play Lerp(3, [&sq])
    play Wait(1)

Uses the shared definitions for this lesson's figures.

When the two expressions do agree

The gap between $(a + b)^2$ and $a^2 + b^2$ is $2ab$, so the two are equal exactly when $2ab = 0$. A product of numbers is zero only when one of the factors is zero, so this happens only when $a = 0$ or $b = 0$. In the figure, that is the case where one part of the side has no length and the strips have no width. For every other pair of numbers, $(a + b)^2$ and $a^2 + b^2$ are different, and they can differ in either direction: if $a$ and $b$ have opposite signs then $2ab$ is negative and $(a + b)^2$ is the smaller of the two. For example $(5 + (-3))^2 = 4$, while $5^2 + (-3)^2 = 34$.

The square of a difference

Because the theorem holds for all real numbers, we may replace $b$ by $-b$. Then $a + (-b) = a - b$, the cross term becomes $2a(-b) = -2ab$, and the last term becomes $(-b)(-b) = b^2$, by the sign rule $(-x)(-y) = xy$. This gives a companion formula with no further proof needed:

$$ (a - b)^2 = a^2 - 2ab + b^2. $$

For positive lengths with $a > b$ there is a picture of this as well. Start with a square of side 10 and remove a strip of width 3 from the right and a strip of height 3 from the top. A square of side 7 remains. Each full strip is 10 by 3, but the two overlap in a 3 by 3 corner, which has therefore been removed twice and must be added back once.

The square of 10 - 3. From a 10 by 10 square, two 10 by 3 strips are removed. They overlap in the green 3 by 3 corner, which is taken away twice and so is added back once: 100 - 60 + 9 = 49 = 7^2.
The square of $10 - 3$. From a 10 by 10 square, two 10 by 3 strips are removed. They overlap in the green 3 by 3 corner, which is taken away twice and so is added back once: $100 - 60 + 9 = 49 = 7^2$.
Monocurl source
let a = 10
let b = 3
let G = 0.33
let X0 = -3.1
let Y0 = -1.6
let r = a - b
mesh pieces = [
    Block([X0, Y0, 0], r, r, G, AZURE),
    Block([X0 + r * G, Y0, 0], b, r, G, EMBER),
    Block([X0, Y0 + r * G, 0], r, b, G, EMBER),
    Block([X0 + r * G, Y0 + r * G, 0], b, b, G, LEAF, 0, 0.4)
]
mesh labels = [
    Tagged([X0 + r * G / 2, Y0 + r * G / 2, 0], eq(r, r), AZURE, 1.75, 0.85),
    Tagged([X0 + (r + b / 2) * G, Y0 + (r + b / 2) * G, 0], str_join(["+", to_string(b * b)]), LEAF, 0.6, 0.85),
    center{[X0 + r * G / 2, Y0 - 0.3, 0]} Math(to_string(r), 0.85, AZURE),
    center{[X0 + (r + b / 2) * G, Y0 - 0.3, 0]} Math(to_string(b), 0.85, EMBER),
    center{[X0 - 0.33, Y0 + r * G / 2, 0]} Math(to_string(r), 0.85, AZURE),
    center{[X0 - 0.33, Y0 + (r + b / 2) * G, 0]} Math(to_string(b), 0.85, EMBER),
    center{[X0 + a * G / 2, Y0 + a * G + 0.3, 0]} Math(to_string(a), 0.85)
]
mesh sums = Column(
    [
        str_join([to_string(a), "^2 = ", to_string(a * a)]),
        str_join(["-2 \times ", to_string(a * b), " = -", to_string(2 * a * b)]),
        str_join(["+", to_string(b), "^2 = +", to_string(b * b)])
    ],
    [INK, EMBER, LEAF],
    str_join([to_string(r), "^2 = ", to_string(r * r)]), 2.3, 1.2, AZURE)

Uses the shared definitions for this lesson's figures.

The difference of two squares

The third identity starts from a different kind of question. Take two squares and subtract the smaller from the larger. For instance $7^2 - 3^2 = 49 - 9 = 40$. Is there anything to notice about the answer?

Pause and try

Compute $5^2 - 2^2$, $7^2 - 3^2$ and $9^2 - 4^2$. Then compute $(5+2)(5-2)$, $(7+3)(7-3)$ and $(9+4)(9-4)$. What do you find?

Show answerHide answer

The differences of squares are $25 - 4 = 21$, $49 - 9 = 40$ and $81 - 16 = 65$. The products are $7 \times 3 = 21$, $10 \times 4 = 40$ and $13 \times 5 = 65$. In each case the difference of the squares equals the sum of the two numbers times their difference.

Three matching cases suggest a rule and do not prove one. The figure shows why the match is not a coincidence, by taking the 40 cells of $7^2 - 3^2$ and physically rearranging them into a 10 by 4 rectangle.

  1. A 7 by 7 square holds 49 cells.
  2. Remove a 3 by 3 square from one corner. An L shape of 49 - 9 = 40 cells is left.
  3. Cut the L into two rectangles: a 7 by 4 piece below and a 4 by 3 piece above.
  4. Turn the small piece and set it beside the large one. The 40 cells now form a 10 by 4 rectangle.
A 7 by 7 square with a 3 by 3 corner removed leaves an L shape of 40 cells. Cutting the L into two rectangles and turning one of them makes a 10 by 4 rectangle, so $7^2 - 3^2 = (7 + 3)(7 - 3)$.
Monocurl source
let a = 7
let b = 3
let G = 0.42
let X0 = -3.4
let Y0 = -1.45
let r = a - b
let Q = |i, j| [X0 + i * G, Y0 + j * G, 0]
# the square with its top right corner removed, drawn as one piece
let Ell = block {
    let pts = [Q(0, 0), Q(a, 0), Q(a, r), Q(r, r), Q(r, a), Q(0, a)]
    . Region(pts, tint(AZURE, 0.22))
    for (i in range(1, a)) {
        var top = a
        if (i > r) { top = r }
        . Seg(Q(i, 0), Q(i, top), tint(AZURE, 0.5), 1.3)
        . Seg(Q(0, i), Q(top, i), tint(AZURE, 0.5), 1.3)
    }
    . Outline(pts, AZURE, 3)
}
let Ghost = [
    fill{tint(SLATE, 0.1)} stroke{MIST, 2.5} Polygon([Q(r, r), Q(a, r), Q(a, a), Q(r, a)]),
    center{Q(r + b / 2, r + b / 2)} Math(eq(b, b), 0.74, SLATE)
]
let Side = |pos, v, col = INK| center{pos} Math(to_string(v), 0.85, col)
mesh ghost = []
mesh big = []
mesh small = []
mesh dims = []
mesh sums = []

slide "A 7 by 7 square holds 49 cells."
    big = Block([X0, Y0, 0], a, a, G, AZURE)
    dims = [Side([X0 + a * G / 2, Y0 - 0.33, 0], a), Side([X0 - 0.33, Y0 + a * G / 2, 0], a)]
    sums = Column([str_join([to_string(a), "^2 = ", to_string(a * a)])], [AZURE], to_string(a * a), 2.5, 0.9)
    play Fade(0.8)

slide "Remove a 3 by 3 square from one corner. An L shape of 49 - 9 = 40 cells is left."
    sums = []
    play Fade(0.3, [&sums])
    big = Ell
    ghost = Ghost
    sums = Column(
        [str_join([to_string(a), "^2 = ", to_string(a * a)]), str_join(["-", to_string(b), "^2 = -", to_string(b * b)])],
        [AZURE, SLATE], to_string(a * a - b * b), 2.5, 1.1)
    play Fade(0.8)

slide "Cut the L into two rectangles: a 7 by 4 piece below and a 4 by 3 piece above."
    dims = []
    play Fade(0.3, [&dims])
    big = Block([X0, Y0, 0], a, r, G, AZURE)
    small = Block(p: [X0, Y0 + r * G + 0.14, 0], r, b, G, PLUM, turn: 0)
    dims = [
        Side([X0 + a * G / 2, Y0 - 0.33, 0], a),
        Side([X0 - 0.33, Y0 + r * G / 2, 0], r),
        Side([X0 - 0.33, Y0 + (r + b / 2) * G + 0.14, 0], b, PLUM),
        Side([X0 + r * G / 2, Y0 + a * G + 0.44, 0], r, PLUM)
    ]
    play Fade(0.8)

slide "Turn the small piece and set it beside the large one. The 40 cells now form a 10 by 4 rectangle."
    dims = []
    ghost = []
    sums = []
    play Fade(0.4, [&dims, &ghost, &sums])
    small.p = [X0 + a * G, Y0 + r * G, 0]
    small.turn = -PI / 2
    play Lerp(1.8, [&small])
    dims = [
        Side([X0 + a * G / 2, Y0 - 0.33, 0], a),
        Side([X0 + (a + b / 2) * G, Y0 - 0.33, 0], b, PLUM),
        Side([X0 - 0.33, Y0 + r * G / 2, 0], r)
    ]
    sums = Column(
        [
            str_join([to_string(a), "^2 - ", to_string(b), "^2 = ", to_string(a * a - b * b)]),
            str_join(["(", to_string(a), "+", to_string(b), ")(", to_string(a), "-", to_string(b), ")"])
        ],
        [INK, INK], str_join(["= ", eq(a + b, r)]), 2.45, 1.1, LEAF)
    play Fade(0.8, [&dims, &sums])

Uses the shared definitions for this lesson's figures.

The L shape has two arms, and both arms have the same thickness, $7 - 3 = 4$, because that is how much of each side is left after the corner is taken out. Equal thickness is what allows one arm to be turned and laid end to end with the other. The combined length is $7 + 3 = 10$: the long arm contributes 7 and the short arm, which had length 3 along the removed corner, contributes 3.

With letters, the L shape left when a square of side $b$ is cut from the corner of a square of side $a$ has arms of thickness $a - b$, and it rearranges into a rectangle of length $a + b$ and height $a - b$.

The rearrangement only makes sense when $a > b > 0$, since otherwise there is no corner to remove. The algebra has no such restriction. In the proof, the two cross terms have opposite signs and cancel, which is the algebraic counterpart of the L shape closing up into a rectangle with nothing left over.

Mental arithmetic with the three identities

These identities are practical. Each one converts a multiplication near a round number into something you can do without paper.

For the square of a number near a multiple of ten, use the square of a sum or of a difference. We have seen $13^2 = 100 + 60 + 9 = 169$. In the same way $99^2 = (100 - 1)^2 = 10000 - 200 + 1 = 9801$.

For a product of two numbers that are equally far from a round number, use the difference of squares. The numbers 47 and 53 are each 3 away from 50, so

$$ 47 \times 53 = (50 - 3)(50 + 3) = 50^2 - 3^2 = 2500 - 9 = 2491. $$

Notice what this says: the product $47 \times 53$ falls short of $50 \times 50$ by exactly $3^2$. Moving two equal factors apart by the same amount in opposite directions always lowers the product, by the square of that amount.

Worked examples

Where the pattern does not extend

The distributive law says that multiplication can be shared out over a sum. It is tempting to assume that every operation can be shared out in the same way, and most cannot. Squaring cannot, as we have seen. Square roots cannot: $\sqrt{9 + 16} = \sqrt{25} = 5$, while $\sqrt{9} + \sqrt{16} = 7$. Division by a sum cannot: $12 \div (2 + 4) = 2$, while $12 \div 2 + 12 \div 4 = 9$.

Division of a sum by a nonzero number $a$ does work, since $(b + c) \div a$ is $(b + c)$ multiplied by $\frac{1}{a}$, and the distributive law applies to that multiplication: $(8 + 4) \div 2 = 4 + 2$. And the roles of the two operations cannot be exchanged: $2 + (3 \times 4) = 14$, while $(2 + 3) \times (2 + 4) = 30$. So whenever you are about to share an operation out over a sum, the safe question to ask is whether the operation is a multiplication by a fixed number. If it is, the law applies. If it is anything else, test with numbers first.

Common mistakes

Stepping back

The difficulty at the start was that a rule which is correct for doubling was being applied to squaring. What resolved it was drawing the product as an area, so that every piece of the product had a place where it could be seen and counted. The cross terms were not visible in the student’s calculation and were impossible to miss in the square.

The reusable idea is that a product of sums is a sum of all the pairwise products, and that the pieces can be organized by a rectangle. That one idea produced the box method for long multiplication, the square of a sum and of a difference, and the difference of squares. The pictures explain the identities for positive lengths, and the proofs from the distributive law extend them to all real numbers.

The next lesson, completing the square, runs the square-of-a-sum picture in reverse. Given $x^2$ and two strips, it asks which corner is needed to finish the square, and the answer leads to the quadratic formula.

Check yourself

Which expression is equal to $(x + 4)^2$ for every value of $x$?

Problems

Problem 1

Use the distributive law to compute each product mentally: (a) $6 \times 104$, (b) $8 \times 99$.

Show solutionHide solution

(a) Write $104 = 100 + 4$. Then $6 \times 104 = 6 \times 100 + 6 \times 4 = 600 + 24 = 624$.

(b) Write $99 = 100 - 1 = 100 + (-1)$. Then $8 \times 99 = 8 \times 100 + 8 \times (-1) = 800 - 8 = 792$.

Problem 2

Expand $(x + 2)(x + 7)$, and check your answer at $x = 1$.

Show solutionHide solution

Multiply each term of the first bracket by each term of the second:

$$ (x + 2)(x + 7) = x^2 + 7x + 2x + 14 = x^2 + 9x + 14. $$

Check at $x = 1$: the original is $3 \times 8 = 24$, and the expansion is $1 + 9 + 14 = 24$.

Problem 3

Compute $21^2$ and $19^2$ using the square of a sum and the square of a difference.

Show solutionHide solution

$21^2 = (20 + 1)^2 = 20^2 + 2 \times 20 \times 1 + 1^2 = 400 + 40 + 1 = 441$.

$19^2 = (20 - 1)^2 = 20^2 - 2 \times 20 \times 1 + 1^2 = 400 - 40 + 1 = 361$.

As a check, the two answers differ by $441 - 361 = 80$, and by the difference of squares $21^2 - 19^2 = (21 + 19)(21 - 19) = 40 \times 2 = 80$.

Problem 4

Compute $98 \times 102$ and $35 \times 25$ using the difference of two squares.

Show solutionHide solution

Both products have factors equally spaced around a convenient number.

$98 \times 102 = (100 - 2)(100 + 2) = 100^2 - 2^2 = 10000 - 4 = 9996$.

$35 \times 25 = (30 + 5)(30 - 5) = 30^2 - 5^2 = 900 - 25 = 875$.

Problem 5

A square garden has side $s$ meters. Each side is lengthened by 1 meter. (a) By how much does the area increase? Give a formula and explain it with a picture of the new garden. (b) Use your formula to get $11^2$ from $10^2$, and $12^2$ from $11^2$.

Show solutionHide solution

(a) The new area is $(s + 1)^2 = s^2 + 2s + 1$, so the increase is $2s + 1$ square meters. In the picture, the new square consists of the old $s$ by $s$ square, two strips that are $s$ by 1, and a 1 by 1 corner. The strips contribute $2s$ and the corner contributes 1.

(b) With $s = 10$ the increase is 21, so $11^2 = 100 + 21 = 121$. With $s = 11$ the increase is 23, so $12^2 = 121 + 23 = 144$. Consecutive squares differ by consecutive odd numbers.

Problem 6

For which values of $x$ is the equation $(x + 3)^2 = x^2 + 9$ true?

Show solutionHide solution

Expand the left side: $(x + 3)^2 = x^2 + 6x + 9$. The equation becomes

$$ x^2 + 6x + 9 = x^2 + 9. $$

Subtracting $x^2 + 9$ from both sides leaves $6x = 0$, so $x = 0$.

The equation is true only when $x = 0$. This agrees with the general statement proved above: $(a + b)^2 = a^2 + b^2$ only when $a = 0$ or $b = 0$, and here $b = 3$ is not zero. A student who “simplifies” $(x + 3)^2$ to $x^2 + 9$ is writing something that is false for every value of $x$ except one.

Problem 7

Find a formula for $(a + b + c)^2$ by drawing a square whose sides are each cut into three parts. Check your formula with $a = 1$, $b = 2$, $c = 3$.

Show solutionHide solution

Cutting each side into parts $a$, $b$, $c$ divides the square into nine pieces, one for each pairing of a part of the horizontal side with a part of the vertical side. Three of them are the squares $a^2$, $b^2$, $c^2$ on the diagonal. The other six come in equal pairs: two of area $ab$, two of area $ac$ and two of area $bc$. So

$$ (a + b + c)^2 = a^2 + b^2 + c^2 + 2ab + 2ac + 2bc. $$

The same result follows from the distributive law by treating $(a + b)$ as one number: $\bigl((a+b) + c\bigr)^2 = (a+b)^2 + 2(a+b)c + c^2$, and expanding.

Check: $(1 + 2 + 3)^2 = 36$, and $1 + 4 + 9 + 4 + 6 + 12 = 36$.

Problem 8

A rectangle has perimeter 40, so its two side lengths add to 20. Write the sides as $10 + d$ and $10 - d$ for some number $d$ with $0 \le d < 10$. Show that the area is largest when the rectangle is a square, and say by how much the area of a 13 by 7 rectangle falls short of the square’s.

Show solutionHide solution

The area is $(10 + d)(10 - d) = 100 - d^2$ by the difference of two squares. Since $d^2 \ge 0$, with equality only when $d = 0$, the area is at most 100 and equals 100 only when $d = 0$. In that case both sides are 10 and the rectangle is a square.

A 13 by 7 rectangle has $d = 3$, so its area is $100 - 9 = 91$, which falls short of the square’s area by $3^2 = 9$. Indeed $13 \times 7 = 91$.

Problem 9

(a) Show that $(a + b)^2 - (a - b)^2 = 4ab$ for all real numbers $a$ and $b$. (b) Check it with $a = 7$, $b = 3$. (c) Deduce that $(a + b)^2 \ge 4ab$ for all real numbers, and say when equality holds.

Show solutionHide solution

(a) Expand both squares:

$$ (a^2 + 2ab + b^2) - (a^2 - 2ab + b^2) = a^2 + 2ab + b^2 - a^2 + 2ab - b^2 = 4ab. $$

Alternatively, use the difference of two squares with $A = a + b$ and $B = a - b$: $(A + B)(A - B) = (2a)(2b) = 4ab$.

(b) $(7 + 3)^2 - (7 - 3)^2 = 100 - 16 = 84$, and $4 \times 7 \times 3 = 84$.

(c) Rearranging part (a), $(a + b)^2 = 4ab + (a - b)^2$. A square of a real number is never negative, so $(a - b)^2 \ge 0$ and therefore $(a + b)^2 \ge 4ab$. Equality holds exactly when $(a - b)^2 = 0$, that is, when $a = b$. For positive lengths there is a picture: four $a$ by $b$ rectangles can be arranged around the inside edge of a square of side $a + b$, leaving a square hole in the middle whose side is the difference between $a$ and $b$.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

let Tagged = |pos, tex, col = INK, pw = 0.6, size = 0.78| [Plate(pos, [pw, 0.38]), center{pos} Math(tex, size, col)]
let plate_w = |v| {
    if (v >= 100) { return 0.78 }
    if (v >= 10) { return 0.6 }
    return 0.42
}
let eq = |x, y| str_join([to_string(x), " \times ", to_string(y), " = ", to_string(x * y)])

# a w by h block of unit cells of size g. p is its lower left corner and turn rotates it about p
let Block = |p, w, h, g, col, turn = 0, amount = 0.22| block {
    let c = cos(turn)
    let s = sin(turn)
    let q = |i, j| [p[0] + (i * c - j * s) * g, p[1] + (i * s + j * c) * g, 0]
    . Region([q(0, 0), q(w, 0), q(w, h), q(0, h)], tint(col, amount))
    for (i in range(1, w)) {
        . Seg(q(i, 0), q(i, h), tint(col, 0.5), 1.3)
    }
    for (j in range(1, h)) {
        . Seg(q(0, j), q(w, j), tint(col, 0.5), 1.3)
    }
    . Outline([q(0, 0), q(w, 0), q(w, h), q(0, h)], col, 3)
}

# a rectangle (a + b) wide and (c + d) tall, lower left corner p, cut into blocks.
# cut 0: one block. cut 1: cut between a and b. cut 2: also cut between c and d.
# cols colours the blocks [a x c, b x c, a x d, b x d]. gap opens the cuts.
# labels 0: none. 1: side lengths. 2: sides and areas. 3: sides, and areas of a x c and b x d only
let Four = |p, a, b, c, d, g, gap, cut, cols, labels = 2| block {
    let x1 = p[0] + a * g + gap
    let y1 = p[1] + c * g + gap
    let mid = |x, w, y, h| [x + w * g / 2, y + h * g / 2, 0]
    let Num = |pos, v, col| Tagged(pos, to_string(v), col, plate_w(v))
    if (cut == 0) {
        . Block(p, a + b, c + d, g, cols[0])
    }
    if (cut == 1) {
        . Block(p, a, c + d, g, cols[0])
        . Block([x1, p[1], 0], b, c + d, g, cols[3])
        if (labels == 2) {
            . Num(mid(p[0], a, p[1], c + d), a * (c + d), cols[0])
            . Num(mid(x1, b, p[1], c + d), b * (c + d), cols[3])
        }
    }
    if (cut == 2) {
        . Block(p, a, c, g, cols[0])
        . Block([x1, p[1], 0], b, c, g, cols[1])
        . Block([p[0], y1, 0], a, d, g, cols[2])
        . Block([x1, y1, 0], b, d, g, cols[3])
        if (labels >= 2) {
            . Num(mid(p[0], a, p[1], c), a * c, cols[0])
            . Num(mid(x1, b, y1, d), b * d, cols[3])
        }
        if (labels == 2) {
            . Num(mid(x1, b, p[1], c), b * c, cols[1])
            . Num(mid(p[0], a, y1, d), a * d, cols[2])
        }
    }
    if (labels >= 1) {
        if (cut == 0) {
            . center{[p[0] + (a + b) * g / 2, p[1] - 0.33, 0]} Math(to_string(a + b), 0.8)
        }
        if (cut >= 1) {
            . center{[p[0] + a * g / 2, p[1] - 0.33, 0]} Math(to_string(a), 0.8)
            . center{[x1 + b * g / 2, p[1] - 0.33, 0]} Math(to_string(b), 0.8)
        }
        if (cut <= 1) {
            . center{[p[0] - 0.36, p[1] + (c + d) * g / 2, 0]} Math(to_string(c + d), 0.8)
        }
        if (cut == 2) {
            . center{[p[0] - 0.36, p[1] + c * g / 2, 0]} Math(to_string(c), 0.8)
            . center{[p[0] - 0.36, y1 + d * g / 2, 0]} Math(to_string(d), 0.8)
        }
    }
}

# a column of lines of arithmetic with a rule and a total under it
let Column = |rows, cols, total, tx = 2.2, top = 1.4, total_col = INK| block {
    for (i in range(0, len(rows))) {
        . center{[tx, top - 0.58 * i, 0]} Math(rows[i], 0.78, cols[i])
    }
    let y = top - 0.58 * len(rows)
    . Seg([tx - 1.15, y + 0.14, 0], [tx + 1.15, y + 0.14, 0], SLATE, 2)
    . center{[tx, y - 0.32, 0]} Math(total, 0.95, total_col)
}