3.6 Multiplying Matrices

When a matrix product is defined and what its dimensions are, the row-by-column recipe for each element, computing a full product, why matrix multiplication is not commutative, and modelling a cost calculation as a matrix product.

Subject: Algebra 2 · 65 slides · symbolic lesson

Open the interactive version of this deck

What this lesson covers

The lesson, slide by slide

1. Lesson 3.6 Multiplying Matrices

Title

Algebra 2 · Chapter 3 — Linear Systems and Matrices

Multiply Matrices

2. By the end of this lesson you can

Objectives

Five outcomes. The first decides whether the rest is even possible.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-201 — the lesson these objectives are drawn from

3. What you already have

Warm-up

Lesson 3.5 added matrices entry by entry, and every operation preserved the dimensions. Multiplication does neither.

Discussion prompt

You have a table of quantities — three products bought by two shops — and a list of three prices. How would you work out each shop's total bill, and how many numbers does the answer have?

Hint: Do one shop first and count the multiplications.

Answer:

For each shop you multiply each quantity by its price and add the three results. That is three multiplications and two additions per shop, giving two totals from six quantities and three prices.

Notice what happened to the shape: a 2 by 3 table and a 3 by 1 list produced a 2 by 1 answer. Matrix multiplication is that calculation, given a name and a rule.

4. Row meets column

Concept

The element in row i, column j of a product comes from row i of the first matrix and column j of the second: multiply corresponding entries and add. Everything else in this lesson follows from that one sentence.

matrix product — The matrix AB, defined when the number of columns of A equals the number of rows of B. Each element pairs a row of A with a column of B.

\[ \begin{bmatrix} a & b \\ c & d \end{bmatrix}\begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} ae+bg & af+bh \\ ce+dg & cf+dh \end{bmatrix} \]

Because a row must pair off against a column, the row and the column have to be the same length — which is the dimension condition, arrived at rather than memorised.

Figure (svg): One row of the first matrix paired with one column of the second, multiplied term by term and summed

Each entry of the product pairs one row with one column, multiplying corresponding terms and adding.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-195 — Multiplying Matrices

5. When is a product defined?

Section

Section 1

6. Inner numbers match; outer numbers give the answer

Concept

Write the two sets of dimensions side by side. The product exists only if the inner two numbers are equal, and when it does exist the outer two numbers are its dimensions.

\[ (m \times n)(n \times p) = m \times p \]

This is not an arbitrary rule. A row of A has n entries and a column of B has as many entries as B has rows, so they can only pair off if those counts agree.

Figure (svg): The dimension rule: the inner numbers must match and the outer numbers give the size of the product

Two numbers decide everything: the inner pair must agree for the product to exist, and the outer pair give its shape.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-195 — Describe matrix products

7. The two numbers that decide everything

Picture it

Write the dimensions next to each other and read the inner and outer pairs.

Figure (svg): The dimension rule: the inner numbers must match and the outer numbers give the size of the product

Two numbers decide everything: the inner pair must agree for the product to exist, and the outer pair give its shape.

A 4 by 3 times a 3 by 2 works and gives a 4 by 2. A 3 by 4 times a 3 by 2 does not, because 4 and 3 disagree — and no amount of care in the arithmetic could rescue it.

8. Worked example: two dimension checks

Worked example

Example 1, both parts.

\[ \text{Is } AB \text{ defined, and what are its dimensions? (a) } A: 4 \times 3, \, B: 3 \times 2. \text{ (b) } A: 3 \times 4, \, B: 3 \times 2. \]

Write the first pair of dimensions side by side

Why: Four by three, then three by two.

\[ 4 x 3\text{ and } 3 x 2 \]

Compare the inner numbers

Why: Three and three — equal, so the product is defined.

\[ 3 = 3,\text{ defined} \]

Read the outer numbers for the answer's shape

Why: Four and two.

\[ AB\text{ is } 4 x 2 \]

Check the second pair

Why: Three by four, then three by two: the inner numbers are 4 and 3, which differ.

Figure (svg): The solution to Worked example two dimension checks shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ \text{(a) } 4 \times 2 \qquad \text{(b) undefined} \]

Verify: say why the second one fails in terms of rows and columns

Why: In the second case a row of A has four entries but a column of B has only three, so there is nothing for the fourth entry of the row to pair with. The dimension rule is that mismatch, stated in shorthand.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-195

9. Defined or not?

Sorting

Compare the inner numbers.

Sort into buckets

Sort each product AB by whether it exists.

Defined
A: 4x3, B: 3x2; A: 5x2, B: 2x2; A: 2x3, B: 3x1
Undefined
A: 3x4, B: 3x2; A: 3x2, B: 3x2
yes
The columns of A equal the rows of B, so every row of A has exactly as many entries as every column of B and the pairing works. The products are 4 by 2, 5 by 2 and 2 by 1 respectively.
no
The inner numbers disagree — 4 against 3, and 2 against 3 — so a row of A and a column of B have different lengths and cannot be paired term by term.

Notice that the two undefined cases would become defined if either matrix were transposed. Order and shape both matter.

10. Worked example: the guided practice pair

Worked example

Guided Practice 1 and 2.

\[ \text{(1) } A: 5 \times 2, \, B: 2 \times 2. \text{ (2) } A: 3 \times 2, \, B: 3 \times 2. \]

Check the first pair's inner numbers

Why: Two and two, so the product exists.

Read its dimensions

Why: The outer numbers are 5 and 2.

\[ AB\text{ is } 5 x 2 \]

Check the second pair

Why: The inner numbers are 2 and 3, which differ.

Notice what the second pair CAN do

Why: Two matrices of identical dimensions can be added, even when they cannot be multiplied. The two conditions are different.

Figure (svg): The solution to Worked example the guided practice pair shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ \text{(1) } 5 \times 2 \qquad \text{(2) undefined} \]

Verify: contrast the two conditions

Why: Addition needs both dimensions to match; multiplication needs only the columns of the first to match the rows of the second. So a 3 by 2 and a 3 by 2 can be added but not multiplied, while a 4 by 3 and a 3 by 2 can be multiplied but not added. The two operations have almost opposite requirements.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-195

11. Trap: the addition condition applied to multiplication

Trap

The trap

\[ A: 3 \times 2, \quad B: 3 \times 2 \]

Say AB is defined because the dimensions are identical

Why: The rule for addition is carried over to multiplication.

Identical dimensions is exactly what ADDITION needs. Multiplication needs the columns of A to match the rows of B, which here is 2 against 3.

The fix

\[ A: 3 \times 2, \quad B: 3 \times 2 \;\Longrightarrow\; AB \text{ undefined} \]

Compare the columns of A with the rows of B

Why: Two columns against three rows: they do not match, so no row of A can pair with a column of B.

These two matrices can be added, and they can be multiplied in neither order. Same dimensions is a hindrance to multiplication, not a help.

12. Give the dimensions of the product

Fill the middle

A is 2 by 3 and B is 3 by 5.

Fill in the blanks

(2 \times 3)(3 \times 5) = 2 \times 5

Why: The inner numbers are both 3, so the product is defined, and the outer numbers 2 and 5 give its dimensions. Note that the product has 10 entries while A has 6 and B has 15 — the shape of the answer matches neither input, which never happens with addition.

13. Can it be multiplied both ways?

Prediction

Commit before reasoning.

Predict first

A is 4 by 3 and B is 3 by 2. Which products are defined?

  • Both AB and BA
  • AB only
  • BA only
  • Neither

Correct: AB only.

\[ AB: (4 \times 3)(3 \times 2) = 4 \times 2 \qquad BA: (3 \times 2)(4 \times 3) \text{ undefined} \]

Why: For AB the inner numbers are 3 and 3, which match. For BA the dimensions read 3 by 2 then 4 by 3, so the inner numbers are 2 and 4, which do not. So one order works and the other does not even exist — a situation with no parallel in ordinary arithmetic, where ab and ba are both always defined.

14. Addition against multiplication

Comparison

Fill the blanks. The two operations demand almost opposite things.

Comparison matrix

FeatureA + BAB
Conditionboth dimensions matchcolumns of A equal rows of B
Dimensions of the resultsame as the inputsrows of A by columns of B
How each entry is builtone sum of two numbersa sum of several products
Order matters?noyes

Every row differs. Addition and multiplication of matrices share a notation and almost nothing else.

15. One element at a time

Section

Section 2

16. Row i, column j, multiplied and summed

Concept

To find the element in row i and column j of AB, take row i of A and column j of B, multiply corresponding entries, and add the products. The position of the answer is named by which row and which column you used.

\[ (AB)_{11} = 1(5) + 4(9) = 41 \]

Row of the FIRST matrix, column of the SECOND. Getting that round the wrong way is what produces BA instead of AB.

Figure (svg): One row of the first matrix paired with one column of the second, multiplied term by term and summed

Each entry of the product pairs one row with one column, multiplying corresponding terms and adding.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-196 — Multiplying Matrices

17. One row, one column, one number

Picture it

Example 2, step one: the top-left entry of the product.

Figure (svg): One row of the first matrix paired with one column of the second, multiplied term by term and summed

Each entry of the product pairs one row with one column, multiplying corresponding terms and adding.

The highlighted row and the highlighted column are both of length two, which is exactly what the dimension condition guaranteed. The answer sits where they cross.

18. Worked example: compute one entry

Worked example

Example 2, step one, in full.

\[ \text{For } A = \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}, \; B = \begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix}, \text{ find the entry in row 1, column 1 of } AB. \]

Take row 1 of A

Why: The entries 1 and 4.

\[ \text{row } 1\text{ of } A: 1, 4 \]

Take column 1 of B

Why: The entries 5 and 9, reading downward.

\[ \text{col } 1\text{ of } B: 5, 9 \]

Multiply corresponding entries

Why: One times five, and four times nine.

\[ 5\text{ and } 36 \]

Add the products

Why: Five plus thirty-six.

\[ 41 \]

Figure (svg): The solution to Worked example compute one entry shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ (AB)_{11} = 1(5) + 4(9) = 41 \]

Verify: check the lengths matched

Why: Row 1 of A had two entries and column 1 of B had two entries, so every term found a partner and none was left over. Had they been different lengths the sum would have been impossible, which is the dimension condition doing its work at the level of a single entry.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196

19. Compute an entry

Fill the middle

Example 2, row 1 column 2.

Fill in the blanks

1(-7) + 4(6) = 17

Why: One times negative seven is negative seven, and four times six is twenty-four; their sum is seventeen. This entry used row 1 of A with column 2 of B, so it belongs in row 1, column 2 of the product — the same row as the previous entry and one column across.

20. Worked example: a different entry

Worked example

Example 2, step three. A different row, so a different position.

\[ \text{Find the entry in row 2, column 1 of } AB \text{ for the same } A \text{ and } B. \]

Take row 2 of A

Why: The entries 3 and negative 2.

\[ \text{row } 2\text{ of } A: 3, -2 \]

Take column 1 of B again

Why: The same column as before: 5 and 9.

\[ \text{col } 1\text{ of } B: 5, 9 \]

Multiply corresponding entries

Why: Three times five is fifteen; negative two times nine is negative eighteen.

\[ 15\text{ and } -18 \]

Add

Why: Fifteen plus negative eighteen.

\[ -3 \]

Figure (svg): The solution to Worked example a different entry shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ (AB)_{21} = 3(5) + (-2)(9) = -3 \]

Verify: confirm the position of the answer

Why: Row 2 of A and column 1 of B were used, so the result belongs in row 2, column 1 of the product. Using the same column with a different row moves the answer down a row and never across, which is a useful check when you are working systematically.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196

21. Trap: entries multiplied position by position

Trap

The trap

\[ \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}\begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix} \]

Multiply the numbers in matching positions, as for addition

Why: The element-by-element rule from Lesson 3.5 is carried over.

\[ \begin{bmatrix} 5 & -28 \\ 27 & -12 \end{bmatrix} \quad \text{(wrong)} \]

Nothing was summed and no row met any column, so this is not the matrix product at all.

The fix

\[ \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}\begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix} = \begin{bmatrix} 41 & 17 \\ -3 & -33 \end{bmatrix} \]

Pair each row of the first with each column of the second, and SUM the products

Why: Every entry of the answer is a sum, not a single product.

The element-wise product exists and has a use in other subjects, but it is not what matrix multiplication means. The row-and-column rule is what makes matrices able to represent systems of equations.

22. Position to its ingredients

Matching

For the product AB of two 2 by 2 matrices.

Match the pairs

  • l1. row 1, column 1 of AB
  • l2. row 1, column 2 of AB
  • l3. row 2, column 1 of AB
  • l4. row 2, column 2 of AB
  • r1. row 1 of A with column 1 of B
  • r2. row 1 of A with column 2 of B
  • r3. row 2 of A with column 1 of B
  • r4. row 2 of A with column 2 of B

Why: The position of an entry names its ingredients exactly: the row number picks the row of A and the column number picks the column of B. That is why the rule is easy to apply systematically — you never have to decide which pieces to use, only to work through the positions in order.

23. How many multiplications?

Prediction

Commit before counting.

Predict first

Computing the product of a 2 by 3 matrix and a 3 by 4 matrix requires how many individual multiplications?

  • 12
  • 24
  • 9
  • 7

Correct: 24 — eight entries, each needing three multiplications.

\[ (2 \times 4) \text{ entries} \times 3 \text{ products each} = 24 \]

Why: The product is 2 by 4, so it has eight entries. Each pairs a row of length three with a column of length three, needing three multiplications and two additions. Eight times three is 24. Counting this before starting tells you how long the calculation will take, and it explains why matrix multiplication by hand is reserved for small matrices.

24. Why must the row and column be the same length?

Explain it to yourself

The dimension condition, explained from the recipe.

\[ (AB)_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots \]

Discussion prompt

Explain why the number of columns of A must equal the number of rows of B, using the way a single entry is computed rather than quoting the rule.

Hint: Ask what pairs up with what.

Answer:

An entry pairs the first item of the row with the first item of the column, the second with the second, and so on. If the row has more items than the column, the extra ones have nothing to multiply.

A row of A has as many entries as A has COLUMNS, and a column of B has as many as B has ROWS. So those two counts must agree, which is exactly the condition. The rule is a consequence of the recipe rather than an extra requirement.

25. Computing a whole product

Section

Section 3

26. Work through the positions in order

Concept

Compute each entry of the product in turn, moving along the first row and then the second. Being systematic is what prevents the commonest error, which is using the wrong row or column somewhere in the middle.

\[ \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}\begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix} = \begin{bmatrix} 41 & 17 \\ -3 & -33 \end{bmatrix} \]

Write the position next to each calculation as you go. It costs nothing and it makes a misplaced entry obvious.

Figure (svg): All four entries of a two by two product, each labelled with the row and column that produced it

Every entry of the product is its own sum of products, built from the row and column that name its position.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196 — Find the product of two matrices

27. Four entries, four calculations

Picture it

Example 2 in full.

Figure (svg): All four entries of a two by two product, each labelled with the row and column that produced it

Every entry of the product is its own sum of products, built from the row and column that name its position.

The first two entries share a row of A and the last two share the other row. Working across a row at a time means you only change one of the two ingredients at each step.

28. Worked example: the full product

Worked example

Example 2, all five steps.

\[ \text{Find } AB \text{ for } A = \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}, \; B = \begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix}. \]

Check the dimensions and note the answer's shape

Why: Two by two times two by two, so the product exists and is two by two.

\[ AB\text{ is } 2 x 2 \]

Row 1 with column 1

Why: One times five plus four times nine.

\[ 5 + 36 = 41 \]

Row 1 with column 2

Why: One times negative seven plus four times six.

\[ -7 + 24 = 17 \]

Row 2 with column 1

Why: Three times five plus negative two times nine.

\[ 15 - 18 = -3 \]

Row 2 with column 2

Why: Three times negative seven plus negative two times six.

\[ -21 - 12 = -33 \]

Figure (svg): The solution to Worked example the full product shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ AB = \begin{bmatrix} 41 & 17 \\ -3 & -33 \end{bmatrix} \]

Verify: recompute one entry from scratch

Why: The bottom-right entry: row 2 of A is 3 and negative 2; column 2 of B is negative 7 and 6. Three times negative seven is negative twenty-one, and negative two times six is negative twelve, giving negative thirty-three. Choosing a different entry to re-derive, rather than re-reading the working, is what makes this a real check.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196

29. Order the steps

Ranking

Computing a matrix product.

Put in order

  1. Write the two sets of dimensions side by side
  2. Check the inner numbers match; stop if they do not
  3. Note the dimensions of the answer from the outer numbers
  4. Compute each entry by pairing the named row with the named column
  5. Recompute one entry from scratch as a check

Why: The dimension check comes first because a product that does not exist is not worth starting. Knowing the answer's shape before computing means you know how many entries to produce, which catches a missed one. And recomputing a single entry independently is a far better check than re-reading, because it uses different arithmetic to reach the same number.

30. Worked example: a non-square product

Worked example

A 2 by 3 times a 3 by 2, where the answer's shape differs from both inputs.

\[ \begin{bmatrix} 2 & 0 & 1 \\ -1 & 3 & 4 \end{bmatrix}\begin{bmatrix} 1 & 2 \\ 0 & -1 \\ 3 & 1 \end{bmatrix} \]

Check the dimensions

Why: The inner numbers are both 3, so the product exists and is 2 by 2.

\[ AB\text{ is } 2 x 2 \]

Row 1 with column 1

Why: Two times one, plus zero times zero, plus one times three.

\[ 2 + 0 + 3 = 5 \]

Row 1 with column 2

Why: Two times two, plus zero times negative one, plus one times one.

\[ 4 + 0 + 1 = 5 \]

Row 2 with column 1

Why: Negative one times one, plus three times zero, plus four times three.

\[ -1 + 0 + 12 = 11 \]

Row 2 with column 2

Why: Negative one times two, plus three times negative one, plus four times one.

\[ -2 - 3 + 4 = -1 \]

Figure (svg): The solution to Worked example a non-square product shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ \begin{bmatrix} 5 & 5 \\ 11 & -1 \end{bmatrix} \]

Verify: check the shape against the dimension rule

Why: A 2 by 3 times a 3 by 2 should give a 2 by 2, and the answer has two rows and two columns. Note that neither input was 2 by 2 — the product's shape came from the outer numbers, not from either matrix, which is unlike anything in Lesson 3.5.

31. Find the error: a column used where a row was needed

Error analysis

A student computes the top-left entry of a product using the wrong pieces.

Annotate

On: \( (AB)_{11} = 1(5) + 3(9) = 32 \quad \text{for } A = \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}, \; B = \begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix} \)

  • The arithmetic is right: one times five plus three times nine really is thirty-two.
  • But the entries 1 and 3 form the first COLUMN of A, not its first row. The rule uses a row of the first matrix.
  • Row 1 of A is 1 and 4, so the entry should be 1(5) plus 4(9), which is 41.
  • The tell is that using a column of A instead of a row computes an entry of a different product entirely - it is part of what you would get from the transpose. Marking the row you are using with a finger prevents it.

Row of the first, column of the second. Saying it aloud each time is slower for a week and reliable thereafter.

32. Complete an entry

Fill the middle

The 2 by 3 times 3 by 2 product from the worked example.

Fill in the blanks

(-1)(1) + 3(0) + 4(3) = 11

Why: Negative one plus zero plus twelve is eleven. The zero term is worth noticing: an entry of zero in either the row or the column contributes nothing, which is why matrices with many zeros are so much faster to multiply — and why the identity matrix of Lesson 3.8 behaves the way it does.

33. Which pieces build this entry?

Discrimination

For a product AB where A is 3 by 2 and B is 2 by 4.

Sort into buckets

Sort each description by whether it correctly names the ingredients of the entry in row 3, column 2 of AB.

Correct
row 3 of A with column 2 of B
Wrong
column 3 of A with row 2 of B; row 2 of A with column 3 of B; row 3 of B with column 2 of A
right
The row number of the entry picks the row of the FIRST matrix and the column number picks the column of the SECOND. Row 3 of A has two entries and column 2 of B has two entries, so they pair correctly.
wrong
Each of these swaps something: rows for columns, the two index numbers, or the two matrices. Note that A has only two columns, so column 3 of A does not exist at all — a wrong description can be impossible as well as merely incorrect.

34. What shape will the answer be?

Prediction

Commit before computing.

Predict first

A is 3 by 2 and B is 2 by 4. What are the dimensions of AB?

  • 3 by 4
  • 2 by 2
  • 3 by 2
  • 4 by 3

Correct: 3 by 4 — the outer numbers.

\[ (3 \times 2)(2 \times 4) = 3 \times 4 \]

Why: The inner numbers are both 2, so the product exists, and the outer numbers 3 and 4 give the dimensions. The answer has twelve entries where A had six and B had eight, which is a good illustration of how differently multiplication treats shape compared with addition — a sum would have had to have exactly the same shape as both inputs.

35. Order matters

Section

Section 4

36. AB and BA are usually different

Concept

For matrices, AB and BA are generally different matrices — and sometimes one is defined while the other is not. Matrix multiplication is not commutative, which is the sharpest break from ordinary arithmetic in this chapter.

\[ AB = \begin{bmatrix} 41 & 17 \\ -3 & -33 \end{bmatrix} \quad BA = \begin{bmatrix} -16 & 34 \\ 27 & 24 \end{bmatrix} \]

The reason is visible in the recipe: AB pairs rows of A with columns of B, and BA pairs rows of B with columns of A. Those are different pairings, so different numbers.

Figure (svg): Two columns showing that AB and BA give different matrices for the same A and B

Same two matrices, opposite order, completely different products.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196 — the note that BA is not the same as AB

37. Two products, same two matrices

Picture it

The A and B of Example 2, multiplied in both orders.

Figure (svg): Two columns showing that AB and BA give different matrices for the same A and B

Same two matrices, opposite order, completely different products.

Not one entry agrees. This is not a near miss caused by rounding — the two products are entirely different matrices.

38. Worked example: compute BA

Worked example

The same matrices as Example 2, in the other order.

\[ \text{Find } BA \text{ for } A = \begin{bmatrix} 1 & 4 \\ 3 & -2 \end{bmatrix}, \; B = \begin{bmatrix} 5 & -7 \\ 9 & 6 \end{bmatrix}. \]

Row 1 of B with column 1 of A

Why: Five times one plus negative seven times three.

\[ 5 - 21 = -16 \]

Row 1 of B with column 2 of A

Why: Five times four plus negative seven times negative two.

\[ 20 + 14 = 34 \]

Row 2 of B with column 1 of A

Why: Nine times one plus six times three.

\[ 9 + 18 = 27 \]

Row 2 of B with column 2 of A

Why: Nine times four plus six times negative two.

\[ 36 - 12 = 24 \]

Figure (svg): The solution to Worked example compute BA shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ BA = \begin{bmatrix} -16 & 34 \\ 27 & 24 \end{bmatrix} \]

Verify: compare with AB entry by entry

Why: AB was 41, 17, negative 3, negative 33; BA is negative 16, 34, 27, 24. Not one of the four positions agrees, and even the signs differ in three of them. The two products are different matrices, which is the point of computing both.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 196-196

39. One of these claims is false

Two truths and a lie

All three are about matrix multiplication.

Eliminate the wrong options

Two of these are true. Knock those out and keep the false one.

  • A. AB and BA can have different dimensions
  • B. AB can be defined while BA is not
  • C. AB always equals BA when both are defined and the same size

Survives elimination: C

Why: The survivor is the false one. Example 2's matrices are both 2 by 2, so both products are defined and both are 2 by 2 — and they still differ in every entry. Same size is not enough; matrix multiplication is simply not commutative, with a few special exceptions such as multiplying by the identity.

40. Worked example: one order defined, the other not

Worked example

A stronger failure of commutativity than merely giving different answers.

\[ \text{For } A: 2 \times 3 \text{ and } B: 3 \times 1, \text{ which of } AB \text{ and } BA \text{ exist?} \]

Check AB

Why: Two by three then three by one: inner numbers 3 and 3, which match.

\[ AB\text{ is } 2 x 1 \]

Check BA

Why: Three by one then two by three: inner numbers 1 and 2, which do not match.

State what this shows

Why: Not only can the two orders give different answers — one of them may not be a legal expression at all.

Compare with numbers

Why: For real numbers ab and ba are both always defined and always equal. Neither holds for matrices.

Figure (svg): The solution to Worked example one order defined, the other not shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ AB: 2 \times 1 \qquad BA: \text{undefined} \]

Verify: say when both orders ARE defined

Why: Both exist only when A is m by n and B is n by m, so that the inner numbers match in each order. Even then AB is m by m and BA is n by n, so unless m equals n the two products are not even the same size — let alone equal.

41. Find the error: commutativity assumed

Error analysis

A student simplifies a matrix expression by reordering a product.

Annotate

On: \( ABC = ACB \quad \text{since multiplication is commutative} \)

  • For real numbers this reasoning is impeccable, and it is exactly what Lesson 1.1's commutative property permits.
  • But matrix multiplication is not commutative, so swapping B and C changes the product - and may make it undefined if the dimensions no longer line up.
  • Example 2 shows the failure concretely: AB and BA share not a single entry for two ordinary 2 by 2 matrices.
  • What IS true is that matrix multiplication is ASSOCIATIVE: (AB)C equals A(BC). Brackets may be moved; the order of the factors may not.

Check which properties survive rather than assuming them all do. Associativity transfers to matrices; commutativity does not.

42. Break a plausible claim

Counterexample

A classmate insists that squaring works the same way for matrices.

\[ (A + B)^2 = A^2 + 2AB + B^2 \]

Discussion prompt

Expand the left side using the distributive property but WITHOUT assuming commutativity, and say where the familiar formula goes wrong.

Hint: Expand carefully and look at the two middle terms.

Answer:

\[ (A+B)(A+B) = A^2 + AB + BA + B^2 \]

The two middle terms are AB and BA, and they cannot be combined into 2AB unless AB happens to equal BA — which for matrices it generally does not.

So the correct expansion keeps both terms separately. Every identity from ordinary algebra that relies on reordering a product has to be re-derived for matrices, and many of them fail.

43. Which properties survive?

Sorting

Some of Lesson 1.1's properties transfer to matrix multiplication and some do not.

Sort into buckets

Sort each property.

Holds for matrices
associative: (AB)C = A(BC); distributive: A(B + C) = AB + AC; commutative for addition: A + B = B + A; associative for addition: (A + B) + C = A + (B + C)
Fails for matrices
commutative: AB = BA
holds
These all survive. Addition is entry by entry, so both of its properties inherit directly from numbers, and multiplication turns out to be associative and distributive even though it is not commutative.
fails
Only the commutativity of multiplication fails, and it fails badly — the two products need not even have the same dimensions. It is the single property worth remembering as lost.

One property out of five. That is why matrix algebra looks so familiar until the moment you try to reorder a product.

44. How sure are you?

Commit first

Answer, then rate your confidence honestly.

Predict first

Are there any pairs of matrices for which AB does equal BA?

  • No, never
  • Yes, in special cases such as multiplying by the identity
  • Yes, whenever both are square
  • Only when both matrices are all zeros

Correct: Yes, in special cases — multiplying by the identity is the standard one.

\[ AI = IA = A \quad \text{for the identity } I \]

Lesson 3.8 makes the identity matrix central, and the fact that it commutes with everything is exactly what makes it behave like the number 1.

Why: Not commutative means it does not hold in general, not that it never holds. The identity matrix commutes with every square matrix of the right size, and so does any scalar multiple of the identity. A matrix also commutes with itself and with its own powers. What is false is the general rule, and relying on it in a particular case requires checking that case.

45. Modelling with a product

Section

Section 5

46. Quantities times prices, all at once

Concept

A matrix of quantities multiplied by a column of prices gives one total per row. The row-times-column rule is exactly the arithmetic a cost calculation already performs, which is what makes matrix multiplication useful rather than merely defined.

\[ \begin{bmatrix} 12 & 45 & 15 \\ 15 & 38 & 17 \end{bmatrix}\begin{bmatrix} 35 \\ 4 \\ 30 \end{bmatrix} = \begin{bmatrix} 1050 \\ 1112 \end{bmatrix} \]

The dimensions carry the meaning: teams by items, times items by one, gives teams by one — one total per team. Checking the dimensions is checking that the model makes sense.

Figure (svg): A quantity matrix multiplied by a cost column, giving one total per team

The row-times-column rule is exactly what a cost calculation already does: quantities against prices, summed.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-195 — in the shape of the textbook's Example 4; the numbers here are built for this deck

47. A cost calculation as a product

Picture it

Two teams, three items, one price list.

Figure (svg): A quantity matrix multiplied by a cost column, giving one total per team

The row-times-column rule is exactly what a cost calculation already does: quantities against prices, summed.

Each row of quantities meets the single column of prices, and the answer has one entry per team. Scalar multiplication could not do this, because the three items have different prices.

48. Worked example: total equipment cost

Worked example

A quantity matrix times a price column. The numbers here are built for this deck.

\[ \text{Team A buys 12 bats, 45 balls, 15 gloves; team B buys 15, 38, 17. Prices are } \$35, \$4, \$30. \]

Arrange the quantities as a matrix

Why: Teams down the side, items across the top: a 2 by 3 matrix.

\[ 2 x 3\text{ quantities} \]

Arrange the prices as a column

Why: One price per item, in the SAME order as the columns of the quantity matrix.

\[ 3 x 1\text{ prices} \]

Check the dimensions

Why: Two by three times three by one: inner numbers match, and the product is 2 by 1 — one total per team.

\[ \text{product is } 2 x 1 \]

Compute team A's total

Why: Twelve times 35, plus 45 times 4, plus 15 times 30.

\[ 420 + 180 + 450 = 1050 \]

Compute team B's total

Why: Fifteen times 35, plus 38 times 4, plus 17 times 30.

\[ 525 + 152 + 510 = 1187 \]

Figure (svg): The solution to Worked example total equipment cost shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ \begin{bmatrix} 1050 \\ 1187 \end{bmatrix} \]

Verify: check the units and one total by hand

Why: Items times dollars per item gives dollars, so the answer's entries really are costs. Team A: 12 bats at 35 is 420, 45 balls at 4 is 180, 15 gloves at 30 is 450, and 420 plus 180 plus 450 is 1050. The matrix product is doing exactly the arithmetic anyone would do by hand, all at once.

49. Build a product from real data

Real world

Three cafes each sell coffee, tea and cake. Yesterday cafe 1 sold 80, 40 and 25; cafe 2 sold 65, 55 and 30; cafe 3 sold 90, 30 and 20. Prices are 3, 2 and 4 dollars.

Discussion prompt

Set this up as a matrix product, state the dimensions at each stage, and compute the revenue for cafe 2. What would you change to compare two different price lists?

Hint: Cafes down the side, items across.

Answer:

\[ (3 \times 3)(3 \times 1) = 3 \times 1 \]

\[ \text{cafe 2}: \; 65(3) + 55(2) + 30(4) = 195 + 110 + 120 = 425 \]

To compare two price lists, widen the price matrix to 3 by 2 — items down, price lists across. The product becomes 3 by 3 times 3 by 2, which is 3 by 2: one revenue figure per cafe per price list, six answers from one multiplication.

50. Worked example: two price lists at once

Worked example

Widening the price matrix to compare two suppliers.

\[ \text{The same quantities, with a second supplier charging } \$32, \$5, \$28. \]

Put both price lists in one matrix

Why: Three items down the side, two suppliers across: a 3 by 2 matrix.

\[ 3 x 2\text{ prices} \]

Check the dimensions

Why: Two by three times three by two gives a 2 by 2 product: two teams by two suppliers.

\[ \text{product is } 2 x 2 \]

Compute team A with supplier 2

Why: Twelve times 32, plus 45 times 5, plus 15 times 28.

\[ 384 + 225 + 420 = 1029 \]

Read what the 2 by 2 answer means

Why: Each entry is one team's total from one supplier, so the matrix answers four questions at once.

Figure (svg): The solution to Worked example two price lists at once shown as a ladder of expressions, one row per algebraic move

The whole solution at once: each drop is one legal move.

\[ \begin{bmatrix} 1050 & 1029 \\ 1187 & 1146 \end{bmatrix} \]

Verify: check that supplier 2 is cheaper for both teams

Why: Team A: 1029 against 1050, so supplier 2 is 21 dollars cheaper. Team B: 1146 against 1187, cheaper by 41 dollars. Supplier 2 charges less for bats and gloves and more for balls, so which is cheaper could in principle have gone either way — the matrix answers it for both teams in one calculation.

51. Find the error: the price list in the wrong order

Error analysis

A student multiplies quantities by prices but arranges the price column carelessly.

Annotate

On: \( \begin{bmatrix} 12 & 45 & 15 \\ 15 & 38 & 17 \end{bmatrix}\begin{bmatrix} 4 \\ 30 \\ 35 \end{bmatrix} \)

  • The dimensions are fine: 2 by 3 times 3 by 1 gives a 2 by 1 product, so the calculation goes through without complaint.
  • But the quantity columns are bats, balls, gloves while the price column is priced balls, gloves, bats. Each quantity is being multiplied by the wrong price.
  • The result, 12(4) + 45(30) + 15(35), is 1923 dollars - a plausible-looking number that answers no question at all.
  • Corrected: the price column must list prices in the SAME order as the quantity columns, giving 35, 4, 30 and a total of 1050.

A matrix carries no labels, so nothing warns you when the orders disagree. Write the labels beside the matrices while setting the problem up, then take them away.

52. Dimensions to meaning

Matching

In a quantity-times-price model.

Match the pairs

  • l1. the rows of the quantity matrix
  • l2. the columns of the quantity matrix
  • l3. the rows of the price matrix
  • l4. the columns of the price matrix
  • r1. the buyers, one per row of the answer
  • r2. the items, which must match the price rows
  • r3. the items again, in the same order
  • r4. the suppliers, one per column of the answer

Why: The inner dimension — the items — is what gets summed over and therefore disappears from the answer. The outer dimensions, buyers and suppliers, survive into the product's shape. That is a general pattern: the thing you multiply and add over vanishes, and the two things you are cross-tabulating remain.

53. What will the answer's shape be?

Prediction

Commit before reasoning.

Predict first

Four shops, six products, and two different price lists. What are the dimensions of the revenue matrix?

  • 4 by 2
  • 4 by 6
  • 6 by 2
  • 2 by 4

Correct: 4 by 2 — shops by price lists.

\[ (4 \times 6)(6 \times 2) = 4 \times 2 \]

Why: The quantity matrix is 4 by 6, shops by products, and the price matrix is 6 by 2, products by price lists. The inner sixes match and vanish, leaving 4 by 2: one revenue figure for each shop under each price list. Predicting the shape before computing tells you how many answers to expect, which is the fastest check that the model was set up the right way round.

54. Why can a scalar not do this?

Socratic

One question, and nothing else on this slide.

\[ \begin{bmatrix} 12 & 45 & 15 \\ 15 & 38 & 17 \end{bmatrix}\begin{bmatrix} 35 \\ 4 \\ 30 \end{bmatrix} \]

Discussion prompt

Lesson 3.5's scalar multiplication also converts quantities into money. Why can it not do this particular calculation, and what does that tell you about what matrix multiplication adds?

Hint: Ask what a scalar would have to assume about the three prices.

Answer:

A scalar multiplies every entry by the SAME number, so it can only handle the case where all three items cost the same. Here bats cost 35 and balls cost 4, so no single multiplier works.

Matrix multiplication allows a different multiplier for each column and then SUMS across the row, which is what turns a table of quantities into a total rather than into another table of the same shape.

That summing is the real addition. Scalar multiplication rescales; matrix multiplication combines and collapses, which is why the answer's shape differs from the input's.

55. Matrix multiplication against everything before it

Comparison

Fill the blanks. This operation breaks every pattern from Lesson 3.5.

Comparison matrix

FeatureAddition (3.5)Multiplication (3.6)
Conditionidentical dimensionscolumns of A equal rows of B
Shape of the answersame as the inputsrows of A by columns of B
Each entry isone suma sum of several products
Commutativeyesno
Associativeyesyes

Four rows differ and one agrees. The surviving associativity is what makes long matrix expressions manageable at all.

56. The procedure, in order

Pattern

One routine computes any matrix product.

  1. Write the two sets of dimensions side by side, in the order the product is written.
  2. Check the inner numbers are equal. If they are not, the product is undefined and there is nothing to compute.
  3. Read the outer numbers to get the dimensions of the answer, and draw an empty grid of that size.
  4. Fill each position by pairing the row of the FIRST matrix named by its row number with the column of the SECOND named by its column number, multiplying corresponding entries and adding.
  5. Recompute one entry independently as a check, and never reorder a product on the assumption that AB equals BA.

Step three's empty grid is worth drawing. It tells you how many entries to produce and stops a missed one from going unnoticed.

OpenStax Algebra and Trigonometry 2e, §11.5 Matrices and Matrix Operations §11.5

57. Check yourself 1 of 3

Check

The dimension rule.

Check your understanding

A is 3 by 4 and B is 4 by 2. Is AB defined, and if so what are its dimensions?

  • A. Defined, and 3 by 2 (correct)
  • B. Defined, and 4 by 4
  • C. Defined, and 3 by 4
  • D. Not defined

Answer: A

Why: The inner numbers are 4 and 4, which match, so the product exists. The outer numbers 3 and 2 give its dimensions.

Why B tempts people
These are the inner numbers, which decide only whether the product exists. The dimensions come from the outer pair.
Why C tempts people
This is the shape of A itself. The product's shape takes its rows from A but its columns from B.
Why D tempts people
The columns of A number 4 and the rows of B number 4, so they do match and the product is defined.

58. Check yourself 2 of 3

Check

One entry of a product. Row of the first, column of the second.

Check your understanding

For A = [[1,4],[3,-2]] and B = [[5,-7],[9,6]], what is the entry in row 2, column 2 of AB?

  • A. -33 (correct)
  • B. -3
  • C. 17
  • D. 24

Answer: A

Why: Row 2 of A is 3 and -2; column 2 of B is -7 and 6. So the entry is 3(-7) + (-2)(6), which is -21 - 12, or -33.

Why B tempts people
This is row 2 with column 1, which is 3(5) + (-2)(9), or -3. It belongs in a different position.
Why C tempts people
This is row 1 with column 2, which is 1(-7) + 4(6), or 17.
Why D tempts people
This is an entry of BA rather than AB — row 2 of B with column 2 of A gives 9(4) + 6(-2), which is 24.

59. Check yourself 3 of 3

Check

The property that fails.

Check your understanding

Which statement about matrix multiplication is FALSE?

  • A. AB always equals BA when both products are defined (correct)
  • B. (AB)C always equals A(BC) when the products are defined
  • C. A(B + C) always equals AB + AC when the operations are defined
  • D. AB may be defined when BA is not

Answer: A

Why: Matrix multiplication is not commutative. For A = [[1,4],[3,-2]] and B = [[5,-7],[9,6]], AB is [[41,17],[-3,-33]] while BA is [[-16,34],[27,24]] — no entry agrees.

Why B tempts people
Associativity does hold for matrices, which is what makes long products unambiguous without extra brackets.
Why C tempts people
The distributive property also holds, which is why expanding matrix expressions works as expected apart from the ordering.
Why D tempts people
This is true and is a stronger failure than mere inequality: if A is 2 by 3 and B is 3 by 1, then AB exists and BA does not.

60. Where this shows up outside the textbook

Real world

A search engine ranks pages by repeatedly multiplying a vector of scores by a matrix describing which pages link to which. A social network finds friends-of-friends by multiplying a connection matrix by itself.

Discussion prompt

In the friends-of-friends case, the connection matrix has a 1 in row i column j when person i knows person j. Explain what the entry in row i, column j of the SQUARE of that matrix counts, using the row-times-column rule.

Hint: Write out what a single term of the sum contributes.

Answer:

The entry pairs row i with column j, so its terms are products of the form: does i know k, times does k know j. Each product is 1 exactly when i knows k AND k knows j, and 0 otherwise.

\[ (A^2)_{ij} = \sum_k a_{ik}a_{kj} \]

Summing over every k therefore COUNTS the number of two-step paths from i to j — the number of mutual friends. The row-times-column rule is not an arbitrary convention; it is the operation that counts paths, which is why the same multiplication turns up in networks, in probability and in geometry.

61. How sure are you?

Commit first

Answer, then rate your confidence honestly.

Predict first

If AB is the zero matrix, must A or B be the zero matrix?

  • Yes, just as with numbers
  • No — two nonzero matrices can multiply to zero
  • Yes, but only for square matrices
  • Only if both are 2 by 2

Correct: No — two nonzero matrices can multiply to give the zero matrix.

\[ \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}\begin{bmatrix} 0 & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} \]

So from AB equal to AC you may NOT conclude that B equals C. Lesson 3.8's inverse matrices are what make cancelling possible, and only for some matrices.

Why: Take A with rows 1, 0 and 0, 0, and B with rows 0, 0 and 0, 1. Neither is the zero matrix, but every entry of AB is a sum of products in which one factor is always zero, so AB is entirely zero. This has no parallel in ordinary arithmetic, where a product of two nonzero numbers is never zero — and it is the reason you cannot cancel matrices the way you cancel numbers.

62. Explain it to someone a year behind you

Explain it

They have just learned to add matrices and expect multiplication to work the same way.

Discussion prompt

In four sentences or fewer, warn them what is different, give them the rule for one entry, and tell them the check to do before starting any product.

Hint: The check is about dimensions.

Answer:

Multiplication is nothing like addition here: you do not multiply matching positions. Each entry of the answer comes from a whole row of the first matrix and a whole column of the second — multiply them term by term and add up.

Before starting, write the two sets of dimensions side by side and check the inner numbers match; if they do not, the product does not exist. And never swap the order, because AB and BA are usually different matrices.

63. Exit ticket

Exit ticket

Name the weakest spot before you close the deck.

Predict first

Which of these would you least want handed to you cold?

  • Deciding whether a product is defined
  • Remembering row of the first, column of the second
  • Keeping track of which position each answer goes in
  • Resisting the urge to reorder a product

Correct: Whichever you picked is tonight's ten minutes, and each has a one-line fix.

Why: For existence, write the dimensions side by side and look at the inner pair. For the rule, say it aloud each time until it is automatic. For positions, draw the empty answer grid first and fill it in order. For reordering, remember Example 2, where AB and BA share not one entry. Do five of your chosen kind rather than twenty mixed ones.

64. Draw the lesson on one page

Connect it up

Paper. Fifteen minutes.

Draw it

At the top of a page write two sets of dimensions side by side, circle the inner pair and box the outer pair, and write beside them what each pair decides. Below, choose two 2 by 2 matrices of your own and compute AB in full, writing the row and column used beside each of the four entries. Then compute BA and write one sentence about how the two answers compare. In the lower half, invent a small quantity-times-price situation with at least two buyers and three items, set it up as a matrix product, label what the rows and columns mean, and compute one total by hand to check. Finally, in a margin, list the four properties from Lesson 1.1 that still hold for matrices and the one that does not.

The margin should show exactly one failure, and it should be the commutativity of multiplication. If you listed more, check each against the worked examples — associativity and distributivity both survive.

65. What you can do now

Recap

Five things, and the fourth is the one that changes how you write everything afterwards.

If you seeThen
Two matrices to multiplyCompare the inner dimensions first
Inner numbers unequalThe product is undefined; stop
An entry to computeRow of the first, column of the second
A product to reorderDo not — check whether it even exists
Quantities and pricesMatch the item orders before multiplying

Lesson 3.7 attaches a single number to a square matrix — its determinant — which will turn out to decide whether a system has a unique solution at all.

McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices §3.6, pp. 195-201 — everything on these slides traces back here

Sources

  1. McDougal Littell Algebra 2 (Texas Edition), Ch. 3 Linear Systems and Matrices — Lesson 3.6 Multiply Matrices — Larson, Boswell, Kanold & Stiff, McDougal Littell / Houghton Mifflin, 2007, pp. 195-201
  2. OpenStax Algebra and Trigonometry 2e, §11.5 Matrices and Matrix Operations
  3. OpenStax College Algebra 2e, §7.5 Matrices and Matrix Operations

Want this taught 1-on-1? Alexander tutors Algebra 2 — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108