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.
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.
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.
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.
- A and B both have order 2 × 3, so the sum or difference exists.
- 2A multiplies every entry of A by 2: 2A has rows (6, −2, 4) and (0, 8, 10).
- Subtract B place by place. Top row: 6 − 1 = 5, −2 − 2 = −4, 4 − (−4) = 8.
- Bottom row: 0 − 6 = −6, 8 − (−3) = 11, 10 − 0 = 10.
- 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.
Worked example
A has rows (1, 2) and (3, 4) and B has rows (2, 0) and (1, 5). Find AB and BA.
- AB, top left: row 1 of A times column 1 of B. 1 × 2 + 2 × 1 = 4.
- AB, top right: row 1 of A times column 2 of B. 1 × 0 + 2 × 5 = 10.
- AB, bottom left: 3 × 2 + 4 × 1 = 10. AB, bottom right: 3 × 0 + 4 × 5 = 20.
- So AB has rows (4, 10) and (10, 20).
- For BA, put B first: top left 2 × 1 + 0 × 3 = 2, and top right 2 × 2 + 0 × 4 = 4.
- Bottom left 1 × 1 + 5 × 3 = 16, and bottom right 1 × 2 + 5 × 4 = 22.
- 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.
- 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.
- Top left: row 1 of P times column 1 of Q. 1 × 2 + 0 × 0 + 2 × 1 = 4.
- Top right: 1 × 1 + 0 × 3 + 2 × (−2) = −3.
- Bottom left: 3 × 2 + 1 × 0 + (−1) × 1 = 5. Bottom right: 3 × 1 + 1 × 3 + (−1) × (−2) = 8.
- So PQ has rows (4, −3) and (5, 8).
- 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 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).
- Top number: row 1 times the vector. 2 × 5 + (−1) × 2 = 8.
- Bottom number: row 2 times the vector. 3 × 5 + 4 × 2 = 23.
- 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
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.
- Write A with rows (1, 2) and (3, 4), and B with rows (2, 0) and (1, 5), side by side on the paper.
- Put one strip under row 1 of A, and another strip beside column 2 of B. These choose the row and the column.
- Multiply the first entries and the second entries of what the strips show, and add. This gives the top right entry of AB.
- 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.
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.
A has rows (1, −2) and (3, 0) and B has rows (4, 5) and (−1, 2). What is A + B?
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.
A has order 2 × 3 and B has order 3 × 4. Which statement is true?
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.
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?
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.
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?
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.
From an earlier chapter
Which vector is a direction vector of the line r = (1, 2) + t(−6, 15)?
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.
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).
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.
A matrix A is 3 × 3. What is A × I, where I is the 3 × 3 identity matrix?
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.
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.