M5.6.6 Chapter 6

Matrices

How can a table of numbers do the work of many sums at once?

Your guess

Pick one before you read on. It is fine to be wrong.

Your guess
  • You picked A. Read on. At the end, the chapter comes back to your guess.

  • You picked B. Read on. At the end, the chapter comes back to your guess.

  • You picked C. Read on. At the end, the chapter comes back to your guess.

By the end you can

  • Add and multiply matrices
  • Show that AB is often not equal to BA

A matrix is a rectangle of numbers in brackets. The numbers are its entries. A matrix with m rows and n columns has order m × n, said "m by n". Rows come first. The matrix below has 2 rows and 3 columns, so its order is 2 × 3. A vector written as a column is a matrix with one column.

A matrix named A with two rows and three columns. The first row reads 3, −1, 2 and the second row reads 0, 4, 5. The matrix is named A.3−12045A
A has 2 rows and 3 columns, so A is a 2 × 3 matrix. The entry in row 1, column 3 is 2.

To add two matrices, add the entries that stand in the same place. This only works if the two matrices have the same order. To subtract, subtract place by place. To multiply a matrix by a number, multiply every entry by it.

A sum of two matrices. A has first row 3, −1 and second row 0, 4. B has first row 1, 2 and second row 6, −3. The result A + B has first row 4, 1 and second row 6, 1. The matrices are named A, B and A + B.3−104A+126−3B=4161A + B
Each entry of A + B is the sum of the two entries in the same place. For example, −1 + 2 = 1 in the top right.

Worked example

A has rows (3, −1, 2) and (0, 4, 5) and B has rows (1, 2, −4) and (6, −3, 0). Find 2A − B.

  1. A and B both have order 2 × 3, so the sum or difference exists.
  2. 2A multiplies every entry of A by 2: 2A has rows (6, −2, 4) and (0, 8, 10).
  3. Subtract B place by place. Top row: 6 − 1 = 5, −2 − 2 = −4, 4 − (−4) = 8.
  4. Bottom row: 0 − 6 = −6, 8 − (−3) = 11, 10 − 0 = 10.
  5. So 2A − B has rows (5, −4, 8) and (−6, 11, 10).

Answer: The matrix has rows (5, −4, 8) and (−6, 11, 10).

Multiplying two matrices is different. To find the entry in row i and column j of the product AB, take row i of A and column j of B. Multiply the first entries, then the second entries, and so on, and add the results. This is the same as the scalar product of the row and the column.

A product of two matrices. A has first row 1, 2 and second row 3, 4, and its first row is ringed with a dashed line. B has first row 2, 0 and second row 1, 5, and its second column is ringed. The product AB has first row 4, 10 and second row 10, 20, with the top right entry ringed. The matrices are named A, B and AB.1234A×2015B=4101020AB
Row 1 of A and column 2 of B give the entry in row 1, column 2 of AB: 1 × 0 + 2 × 5 = 10.

Worked example

A has rows (1, 2) and (3, 4) and B has rows (2, 0) and (1, 5). Find AB and BA.

  1. AB, top left: row 1 of A times column 1 of B. 1 × 2 + 2 × 1 = 4.
  2. AB, top right: row 1 of A times column 2 of B. 1 × 0 + 2 × 5 = 10.
  3. AB, bottom left: 3 × 2 + 4 × 1 = 10. AB, bottom right: 3 × 0 + 4 × 5 = 20.
  4. So AB has rows (4, 10) and (10, 20).
  5. For BA, put B first: top left 2 × 1 + 0 × 3 = 2, and top right 2 × 2 + 0 × 4 = 4.
  6. Bottom left 1 × 1 + 5 × 3 = 16, and bottom right 1 × 2 + 5 × 4 = 22.
  7. So BA has rows (2, 4) and (16, 22). AB and BA are different.

Answer: AB has rows (4, 10) and (10, 20). BA has rows (2, 4) and (16, 22).

Because AB depends on the order, we say that matrix multiplication is not commutative. Worse, the product may not exist at all. For row i of A to meet column j of B, they must have the same length. So the number of columns of A must equal the number of rows of B. If A is m × n and B is n × p, then AB is m × p.

Worked example

P has rows (1, 0, 2) and (3, 1, −1) and Q has rows (2, 1) and (0, 3) and (1, −2). Find PQ, and say whether QP exists.

  1. P is 2 × 3 and Q is 3 × 2. The inner numbers are both 3, so PQ exists. Its order is 2 × 2, the outer numbers.
  2. Top left: row 1 of P times column 1 of Q. 1 × 2 + 0 × 0 + 2 × 1 = 4.
  3. Top right: 1 × 1 + 0 × 3 + 2 × (−2) = −3.
  4. Bottom left: 3 × 2 + 1 × 0 + (−1) × 1 = 5. Bottom right: 3 × 1 + 1 × 3 + (−1) × (−2) = 8.
  5. So PQ has rows (4, −3) and (5, 8).
  6. For QP, Q is 3 × 2 and P is 2 × 3. The inner numbers are both 2, so QP exists too. But its order is 3 × 3, so QP is a different size from PQ.

Answer: PQ has rows (4, −3) and (5, 8). QP exists and is 3 × 3.

Some rules do hold. Multiplication is associative: (AB)C = A(BC). It spreads over addition: A(B + C) = AB + AC. And there is a matrix that does nothing, the identity matrix I, with 1s on the diagonal from the top left and 0s elsewhere. For a 2 × 2 matrix it has rows (1, 0) and (0, 1). Then A × I = I × A = A, as 1 does for numbers.

A product of two matrices. The first is A with first row 3, 1 and second row 2, 5. The second is the identity matrix I with first row 1, 0 and second row 0, 1. The result is A again. The matrices are named A, I and A.3125A×1001I=3125A
Multiplying by the identity matrix I leaves A as it was.

A 2 × 2 matrix times a column vector is the same rule, with a column that has just one column. Row 1 of the matrix times the vector gives the top number, and row 2 times the vector gives the bottom number. The result is a new vector. In the next chapter, this is how a matrix moves points.

Worked example

Find the vector made by the matrix with rows (2, −1) and (3, 4) acting on the vector (5, 2).

  1. Top number: row 1 times the vector. 2 × 5 + (−1) × 2 = 8.
  2. Bottom number: row 2 times the vector. 3 × 5 + 4 × 2 = 23.
  3. The new vector is (8, 23).

Answer: (8, 23)

See it three ways

With things

A seller packs two kinds of basket. A small one holds 2 mangoes and 1 papaya. A large one holds 4 mangoes and 3 papayas. On the first day, 3 small and 1 large basket are ordered. On the second day, 2 small and 4 large are ordered. How many fruits go out each day?

As a picture

A product of two matrices. The orders matrix has first row 3, 1 and second row 2, 4. The baskets matrix has first row 2, 1 and second row 4, 3. The result has first row 10, 6 and second row 20, 14. The matrices are named orders, baskets and fruit.3124orders×2143baskets=1062014fruit

In words

Each row of the orders matrix is a day. Each column of the baskets matrix is a kind of fruit. Row by column gives the fruit for each day. Day 1: 3 × 2 + 1 × 4 = 10 mangoes, and 6 papayas.

In symbols

The columns of orders match the rows of baskets, so the product exists. The first column of the answer is mangoes and the second is papayas.

Try it

Multiply with two strips of paper

You need: paper, a pencil, two strips of card or a ruler.

  1. Write A with rows (1, 2) and (3, 4), and B with rows (2, 0) and (1, 5), side by side on the paper.
  2. Put one strip under row 1 of A, and another strip beside column 2 of B. These choose the row and the column.
  3. Multiply the first entries and the second entries of what the strips show, and add. This gives the top right entry of AB.
  4. Move the strips to each other row and column to fill in all four entries.

What you will see: The four entries are 4, 10, 10 and 20. Every entry used one row and one column, so the strips cannot go wrong.

If you cannot try it, this is what happens.
A product of two matrices. A has first row 1, 2 and second row 3, 4, and its second row is ringed with a dashed line. B has first row 2, 0 and second row 1, 5, and its first column is ringed. The product AB has first row 4, 10 and second row 10, 20, with the bottom left entry ringed. The matrices are named A, B and AB.1234A×2015B=4101020AB

A wrong idea many people have

AB is the same as BA.

Why it feels right: With numbers, 3 × 5 and 5 × 3 are the same, so multiplication seems free of order.

The test that breaks it: Take A with rows (1, 2) and (3, 4) and B with rows (2, 0) and (1, 5). The top left entry of AB is 1 × 2 + 2 × 1 = 4. The top left entry of BA is 2 × 1 + 0 × 3 = 2. They differ.

What is true: Matrix multiplication depends on the order. Sometimes AB = BA, but you must not assume it. Write products in the order given, and in an equation, multiply on the same side of both sides.

A wrong idea many people have

To multiply two matrices, multiply the entries in the same places.

Why it feels right: Addition works place by place, so multiplication seems to do the same.

The test that breaks it: Multiply place by place for the matrices above. The top right entry would be 2 × 0 = 0. But the row by column rule gives 10, which is what is needed to represent combined sums, as in the basket story.

What is true: The entry in row i and column j of AB is row i of A times column j of B, added up. Place by place multiplication is a different operation and is not the matrix product.

Key words

matrix
a rectangle of numbers in rows and columns.
order
the size of a matrix: m × n means m rows and n columns.
entry
one number inside a matrix.
identity matrix
the square matrix I with 1s on the diagonal and 0s elsewhere. A × I = I × A = A.
not commutative
the order matters: AB is often not equal to BA.

Back to your guess

The answer is B: If A has rows (1, 2) and (3, 4) and B has rows (0, 1) and (1, 0), then AB and BA are different matrices.

AB has rows (2, 1) and (4, 3), which is A with its columns swapped. BA has rows (3, 4) and (1, 2), which is A with its rows swapped. They differ. Matrices multiply by a row by column rule that depends on the order, and this chapter shows the rule.

Check yourself

Try each one before you look. A wrong answer tells you where to go next.

  1. A has rows (1, −2) and (3, 0) and B has rows (4, 5) and (−1, 2). What is A + B?

    Tap your answer.
    1. Not this one. You multiplied the matrices. The sign asks for a sum, so add the entries in the same places. Read this page again. Try another.

    2. Yes, that is right. Add the entries place by place: 1 + 4, −2 + 5, 3 + (−1) and 0 + 2. The sum has rows (5, 3) and (2, 2).

    3. Not this one. You subtracted. The sign is +, so add the entries in the same places. Read this page again. Try another.

    4. Not this one. The bottom left entry is wrong. Check it again: 3 + (−1). Read this page again. Try another.

    See the answer

    rows (5, 3) and (2, 2)

    Add the entries place by place: 1 + 4, −2 + 5, 3 + (−1) and 0 + 2. The sum has rows (5, 3) and (2, 2).

    • If you chose A: You multiplied the matrices. The sign asks for a sum, so add the entries in the same places. Read this page again.
    • If you chose C: You subtracted. The sign is +, so add the entries in the same places. Read this page again.
    • If you chose D: The bottom left entry is wrong. Check it again: 3 + (−1). Read this page again.
  2. A has order 2 × 3 and B has order 3 × 4. Which statement is true?

    Tap your answer.
    1. Not this one. The order of AB is the outer numbers, 2 and 4, not the inner numbers. Read this page again. Try another.

    2. Not this one. The columns of A (3) match the rows of B (3), so AB can be found. Read this page again. Try another.

    3. Yes, that is right. For AB, A has 3 columns and B has 3 rows, so the product exists. Its order is the outer numbers: 2 rows from A and 4 columns from B, so 2 × 4.

    4. Not this one. BA cannot be found: B has 4 columns but A has only 2 rows. The inner numbers 4 and 2 must be equal. Read this page again. Try another.

    See the answer

    AB has order 2 × 4.

    For AB, A has 3 columns and B has 3 rows, so the product exists. Its order is the outer numbers: 2 rows from A and 4 columns from B, so 2 × 4.

    • If you chose A: The order of AB is the outer numbers, 2 and 4, not the inner numbers. Read this page again.
    • If you chose B: The columns of A (3) match the rows of B (3), so AB can be found. Read this page again.
    • If you chose D: BA cannot be found: B has 4 columns but A has only 2 rows. The inner numbers 4 and 2 must be equal. Read this page again.
  3. The picture shows the product AB. The ringed row of A and the ringed column of B meet to give one entry of AB. Which entry is it?

    A product of two matrices. A has first row 3, 1 and second row 2, 5, and its second row is ringed with a dashed line. B has first row 2, 6 and second row 4, 1, and its first column is ringed. The result AB has four entries, marked with question marks. The matrices are named A, B and AB.3125A×2641B=????AB
    Tap your answer.
    1. Not this one. The top right entry uses row 1 of A and column 2 of B. The ringed row is row 2 and the ringed column is column 1. Read this page again. Try another.

    2. Not this one. The top left entry uses row 1 of A. The ringed row is row 2. Read this page again. Try another.

    3. Not this one. The bottom right entry uses column 2 of B. The ringed column is column 1. Read this page again. Try another.

    4. Yes, that is right. The ringed row is row 2 of A and the ringed column is column 1 of B. Row 2 and column 1 give the entry in the bottom left. It is 2 × 2 + 5 × 4 = 24.

    See the answer

    Bottom left

    The ringed row is row 2 of A and the ringed column is column 1 of B. Row 2 and column 1 give the entry in the bottom left. It is 2 × 2 + 5 × 4 = 24.

    • If you chose A: The top right entry uses row 1 of A and column 2 of B. The ringed row is row 2 and the ringed column is column 1. Read this page again.
    • If you chose B: The top left entry uses row 1 of A. The ringed row is row 2. Read this page again.
    • If you chose C: The bottom right entry uses column 2 of B. The ringed column is column 1. Read this page again.
  4. A has rows (2, 1) and (0, 3) and B has rows (1, 4) and (5, 2). What is the top right entry of AB?

    Tap your answer.
    1. Not this one. That is the top left entry. The top right entry uses column 2 of B, (4, 2). Read this page again. Try another.

    2. Yes, that is right. Row 1 of A is (2, 1) and column 2 of B is (4, 2). 2 × 4 + 1 × 2 = 10.

    3. Not this one. You multiplied entries in the same place only. Multiply row 1 of A by column 2 of B, and add both products. Read this page again. Try another.

    4. Not this one. That is the bottom right entry. The top right uses row 1 of A. Read this page again. Try another.

    See the answer

    10

    Row 1 of A is (2, 1) and column 2 of B is (4, 2). 2 × 4 + 1 × 2 = 10.

    • If you chose A: That is the top left entry. The top right entry uses column 2 of B, (4, 2). Read this page again.
    • If you chose C: You multiplied entries in the same place only. Multiply row 1 of A by column 2 of B, and add both products. Read this page again.
    • If you chose D: That is the bottom right entry. The top right uses row 1 of A. Read this page again.
  5. From an earlier chapter

    Which vector is a direction vector of the line r = (1, 2) + t(−6, 15)?

    Tap your answer.
    1. Yes, that is right. Any non-zero multiple of (−6, 15) is a direction vector. A third of it is (−2, 5).

    2. Not this one. This swaps the two parts. It points a different way from the direction. Go to M5.6.5. Try another.

    3. Not this one. This is the starting point, not the direction. Go to M5.6.5. Try another.

    See the answer

    (−2, 5)

    Any non-zero multiple of (−6, 15) is a direction vector. A third of it is (−2, 5).

    • If you chose B: This swaps the two parts. It points a different way from the direction. Go to M5.6.5.
    • If you chose C: This is the starting point, not the direction. Go to M5.6.5.
  6. Find the top left entry of AB when A has rows (1, 3) and (2, 4) and B has rows (2, 5) and (1, 0).

    See the answer

    5

    Row 1 of A is (1, 3) and column 1 of B is (2, 1). 1 × 2 + 3 × 1 = 5.

  7. The matrix with rows (3, 1) and (−2, 4) acts on the vector (2, 5). Give the new vector as (top, bottom).

    See the answer

    (11, 16)

    Top: 3 × 2 + 1 × 5 = 11. Bottom: (−2) × 2 + 4 × 5 = 16. The new vector is (11, 16).

  8. A has rows (2, 3) and (−1, 4) and B has rows (1, −2) and (5, 0). Find the top left entry of AB and the top left entry of BA. Give them in that order.

    See the answer

    17 and 4

    AB: 2 × 1 + 3 × 5 = 17. BA: 1 × 2 + (−2) × (−1) = 4. The two entries differ, so AB is not equal to BA.

  9. A matrix A is 3 × 3. What is A × I, where I is the 3 × 3 identity matrix?

    Tap your answer.
    1. Not this one. The identity leaves A unchanged, so the product is A, not I. Read this page again. Try another.

    2. Yes, that is right. The identity matrix does for matrices what 1 does for numbers. A × I = A, and I × A = A.

    3. Not this one. Multiplying by I is not multiplying by 0. The identity acts like the number 1. Read this page again. Try another.

    See the answer

    A

    The identity matrix does for matrices what 1 does for numbers. A × I = A, and I × A = A.

    • If you chose A: The identity leaves A unchanged, so the product is A, not I. Read this page again.
    • If you chose C: Multiplying by I is not multiplying by 0. The identity acts like the number 1. Read this page again.
  10. P has rows (2, −1, 0) and (1, 3, 2) and Q has rows (1, 2) and (4, 0) and (−3, 5). Find the entry in row 2, column 2 of PQ.

    See the answer

    12

    Row 2 of P is (1, 3, 2) and column 2 of Q is (2, 0, 5). 1 × 2 + 3 × 0 + 2 × 5 = 12.

Keep it

Copy this into your exercise book.

Order m × n: rows first. Add place by place. AB: row i of A times column j of B, added. A is m × n, B is n × p, so AB is m × p. AB is not BA. A × I = A.

Draw: Two matrices with a row of the first and a column of the second ringed, and the entry they make.

Reading with a child? A short page for the adult: what this chapter teaches and three questions to ask.

No internet tomorrow? Save the whole book as one file (864 KB). It opens on any phone.