Skip to the page
Home Campus
Start free

Multiplying Two Matrices

How to multiply two matrices: a row times a column, when a product can be found and what its order is, row by column for every element, why AB and BA differ, squares, and unknowns in a product.

Before you start

You will multiply many negative numbers (Secondary 1): (−1)×(−2)=2(-1) \times (-2) = 2, 3×(−2)=−63 \times (-2) = -6.

In lesson 4.3 every element of a matrix was multiplied by the same number, as below. Multiplying two matrices is different: the rows of the first meet the columns of the second.

2
3−1
04
=
6−2
08

A Row Times a Column

At the food stall of lesson 4.1, mee rebus costs $4, nasi lemak $3 and mee soto $5. A family buys 3 plates of mee rebus, 2 of nasi lemak and 1 of mee soto. Their meal costs 3×4+2×3+1×5=233 \times 4 + 2 \times 3 + 1 \times 5 = 23 dollars: each number of plates times its price, then added.

With the plates as a row matrix and the prices as a column matrix, this is how a row is multiplied by a column: first element times first element, second times second, third times third, and the products added. The answer is a 1×11 \times 1 matrix.

A row times a column

Multiply the elements in pairs, first with first, second with second, and so on, and add the products.

The row and the column must have the same number of elements.

The answer is a matrix of order 1×11 \times 1, written in brackets, such as (23).

Example 1: The Cost of a Meal

Work out the product of the row of plates and the column of prices, and say what it means.

321
4
3
5

Solution

Pair the elements, first with first, second with second, third with third; multiply, then add:

321
4
3
5
=
3 × 4 + 2 × 3 + 1 × 5
=
12 + 6 + 5
=
23

The plates are counted and the prices are in dollars, so the answer is the cost of the meal in dollars.

The product is the 1×11 \times 1 matrix (23): the meal costs $23.

When Can Two Matrices Be Multiplied?

To multiply two matrices, each row of the first is multiplied by each column of the second, as above. So a row of the first must have as many elements as a column of the second: the number of columns of the first must equal the number of rows of the second.

When a product can be found, and its order

Write the two orders side by side. For a 2×32 \times 3 matrix times a 3×23 \times 2 matrix: (2×3)(3×2)(2 \times 3)(3 \times 2).

The inner numbers (3 and 3) must be equal; if they are not, the product cannot be found.

The outer numbers (2 and 2) give the order of the product: 2×22 \times 2.

In short: (a×b)(b×c)(a \times b)(b \times c) gives a×ca \times c.

Example 2: Which Products Can Be Found?

A is a 2×32 \times 3 matrix, B is 3×23 \times 2 and C is 2×22 \times 2. Which of AB, BA, AC, CA, BC and CB can be found? Give the order of each one that can.

Solution

AB: (2×3)(3×2)(2 \times 3)(3 \times 2). The inner numbers 3 and 3 agree, so AB can be found; its order is 2×22 \times 2.

BA: (3×2)(2×3)(3 \times 2)(2 \times 3). 2 and 2 agree; the order is 3×33 \times 3.

AC: (2×3)(2×2)(2 \times 3)(2 \times 2). 3 and 2 differ, so AC cannot be found. (Some books say AC does not exist, or is not defined.)

CA: (2×2)(2×3)(2 \times 2)(2 \times 3). 2 and 2 agree; the order is 2×32 \times 3.

BC: (3×2)(2×2)(3 \times 2)(2 \times 2). 2 and 2 agree; the order is 3×23 \times 2.

CB: (2×2)(3×2)(2 \times 2)(3 \times 2). 2 and 3 differ: CB cannot be found.

AB 2×22 \times 2, BA 3×33 \times 3, CA 2×32 \times 3, BC 3×23 \times 2; AC and CB cannot be found.

Row by Column

The elements of a product

The element in row 2, column 1 of AB comes from row 2 of A and column 1 of B: multiply that row by that column, as in Example 1.

In the same way, every element of AB is a row of A times a column of B. Work out one element at a time, and write the working inside the brackets.

AB means A first, then B: the rows come from A, the columns from B.

Example 3: Two 2 × 2 Matrices

Find AB.

A=
21
3−1
B=
40
−25

Solution

(2×2)(2×2)(2 \times 2)(2 \times 2): the product can be found and is 2×22 \times 2.

Row 1, column 1: row 1 of A is 2, 1 and column 1 of B is 4, −2: 2×4+1×(−2)=8−2=6.2 \times 4 + 1 \times (-2) = 8 - 2 = 6\text{.}

Row 1, column 2: 2, 1 with 0, 5: 2×0+1×5=52 \times 0 + 1 \times 5 = 5. Row 2 of A is 3, −1; with column 1: 3×4+(−1)×(−2)=12+2=14;3 \times 4 + (-1) \times (-2) = 12 + 2 = 14\text{;} with column 2: 3×0+(−1)×5=−5.3 \times 0 + (-1) \times 5 = -5\text{.}

All four inside the brackets:

AB=
2 × 4 + 1 × (−2)2 × 0 + 1 × 5
3 × 4 + (−1) × (−2)3 × 0 + (−1) × 5
=
8 − 20 + 5
12 + 20 − 5
=
65
14−5

The product:

AB=
65
14−5

Example 4: A 2 × 3 Matrix Times a 3 × 2 Matrix

Find PQ.

P=
120
3−14
Q=
21
03
5−2

Solution

(2×3)(3×2)(2 \times 3)(3 \times 2): the inner numbers agree, and PQ is 2×22 \times 2. Each element is a row of three elements times a column of three.

PQ=
1 × 2 + 2 × 0 + 0 × 51 × 1 + 2 × 3 + 0 × (−2)
3 × 2 + (−1) × 0 + 4 × 53 × 1 + (−1) × 3 + 4 × (−2)
=
2 + 0 + 01 + 6 + 0
6 + 0 + 203 − 3 − 8
=
27
26−8

Row 2, column 2, for example: row 2 of P is 3, −1, 4 and column 2 of Q is 1, 3, −2: 3−3−8=−83 - 3 - 8 = -8.

A 2×22 \times 2 matrix:

PQ=
27
26−8

AB and BA Are Not the Same

Numbers can be multiplied either way round: x×y=y×xx \times y = y \times x (Secondary 1). Matrices cannot. In general AB ≠ BA: one may be found and the other not (Example 2), the two may have different orders, or both may be 2×22 \times 2 and still be different.

So always multiply the matrices the way round they are written: AB is A first, then B.

Example 5: The Other Way Round

With the matrices of Examples 3 and 4, find (a) BA, and compare it with AB; (b) QP, and compare it with PQ.

Solution

(a) Now the rows come from B and the columns from A:

BA=
4 × 2 + 0 × 34 × 1 + 0 × (−1)
(−2) × 2 + 5 × 3(−2) × 1 + 5 × (−1)
=
84
11−7
AB≠BA

AB and BA are both 2×22 \times 2, but their elements differ.

(b) (3×2)(2×3)(3 \times 2)(2 \times 3): QP is 3×33 \times 3. Each element is a row of two elements of Q times a column of two of P:

QP=
2 × 1 + 1 × 32 × 2 + 1 × (−1)2 × 0 + 1 × 4
0 × 1 + 3 × 30 × 2 + 3 × (−1)0 × 0 + 3 × 4
5 × 1 + (−2) × 35 × 2 + (−2) × (−1)5 × 0 + (−2) × 4
=
534
9−312
−112−8

PQ is 2×22 \times 2 but QP is 3×33 \times 3: they do not even have the same order.

AB ≠ BA, and PQ and QP have different orders.

BA=
84
11−7
QP=
534
9−312
−112−8

The Square of a Matrix

A²

A2\mathbf{A}^2 means AA: the matrix multiplied by itself, row by column.

It can be found only for a square matrix: a 2×32 \times 3 matrix has no square, as (2×3)(2×3)(2 \times 3)(2 \times 3) cannot be found.

It is not found by squaring each element.

Example 6: A Square

With A from Example 3, find A2\mathbf{A}^2. Can P2\mathbf{P}^2 be found, for P from Example 4?

A=
21
3−1

Solution

A2=
21
3−1
21
3−1
=
2 × 2 + 1 × 32 × 1 + 1 × (−1)
3 × 2 + (−1) × 33 × 1 + (−1) × (−1)
=
71
34

Squaring each element would give 4, 1 in row 1 and 9, 1 in row 2, which is wrong:

A2≠
41
91

P is 2×32 \times 3, not square:

P2cannot be found: a 2 × 3 matrix is not square.

P2\mathbf{P}^2 cannot be found.

A2=
71
34

Unknowns in a Product

Multiply out the product, element by element, with the unknowns in it. Then equate corresponding elements and solve, starting with an equation that has only one unknown.

Example 7: Two Unknowns

Find xx and yy.

2x
13
4
y
=
14
13

Solution

(2×2)(2×1)(2 \times 2)(2 \times 1) gives a 2×12 \times 1 matrix:

2x
13
4
y
=
2 × 4 + x × y
1 × 4 + 3 × y
=
xy + 8
3y + 4
=
14
13

Row 2 has one unknown: 3y+4=133y + 4 = 13, so 3y=93y = 9 and y=3y = 3.

Row 1: xy+8=14xy + 8 = 14, so xy=6xy = 6. With y=3y = 3: 3x=63x = 6 and x=2x = 2.

Check: 2×4+2×3=142 \times 4 + 2 \times 3 = 14 and 1×4+3×3=131 \times 4 + 3 \times 3 = 13.

x=2x = 2, y=3y = 3

Common Mistakes

  • Multiplying corresponding elements, as in a sum. A product is rows of the first times columns of the second.
  • Giving the wrong order to the product: (2×3)(3×2)(2 \times 3)(3 \times 2) is 2×22 \times 2, from the outer numbers.
  • Taking a column of the first matrix with a row of the second.
  • Losing a sign in a long row: 3×1+(−1)×3+4×(−2)=3−3−8=−8.3 \times 1 + (-1) \times 3 + 4 \times (-2) = 3 - 3 - 8 = -8\text{.}
  • Treating AB and BA as equal, or working out BA when AB is asked.
  • Squaring each element for A2\mathbf{A}^2. A2=AA\mathbf{A}^2 = \mathbf{AA}.

Practice

Try each question before you open its solution. Questions 5 and 12 are word problems.

Question 1

Say whether each product can be found, and if so give its order. The orders of the two matrices are (a) (2×3)(3×4)(2 \times 3)(3 \times 4) (b) (3×1)(1×3)(3 \times 1)(1 \times 3) (c) (1×3)(3×1)(1 \times 3)(3 \times 1) (d) (2×2)(3×2)(2 \times 2)(3 \times 2) (e) (4×2)(2×1)(4 \times 2)(2 \times 1) (f) (1×2)(1×2)(1 \times 2)(1 \times 2)

ShowHide solution

(a) 3 and 3 agree: 2×42 \times 4. (b) 1 and 1 agree: 3×33 \times 3. (c) 3 and 3 agree: 1×11 \times 1.

(d) 2 and 3 differ: cannot be found. (e) 2 and 2 agree: 4×14 \times 1. (f) 2 and 1 differ: cannot be found.

(a) 2×42 \times 4 (b) 3×33 \times 3 (c) 1×11 \times 1 (d) cannot be found (e) 4×14 \times 1 (f) cannot be found

Question 2

Work out the product.

1−2
30
5
2
ShowHide solution

(2×2)(2×1)(2 \times 2)(2 \times 1) gives 2×12 \times 1:

1−2
30
5
2
=
1 × 5 + (−2) × 2
3 × 5 + 0 × 2
=
5 − 4
15 + 0
=
1
15

A 2×12 \times 1 matrix:

1−2
30
5
2
=
1
15

Question 3

Work out the product.

20−1
31
4−2
15
ShowHide solution

(1×3)(3×2)(1 \times 3)(3 \times 2) gives 1×21 \times 2: the row times each column in turn.

20−1
31
4−2
15
=
2 × 3 + 0 × 4 + (−1) × 12 × 1 + 0 × (−2) + (−1) × 5
=
6 + 0 − 12 + 0 − 5
=
5−3

A 1×21 \times 2 matrix:

20−1
31
4−2
15
=
5−3

Question 4

Work out the product of the column and the row.

2
3
14
ShowHide solution

(2×1)(1×2)(2 \times 1)(1 \times 2): the inner numbers 1 and 1 agree, and the product is 2×22 \times 2. Each "row times column" is a single pair:

2
3
14
=
2 × 12 × 4
3 × 13 × 4
=
28
312

A 2×22 \times 2 matrix:

2
3
14
=
28
312

Question 5

The matrix G gives the goals scored by three players (rows) in two matches (columns). Work out (1 1 1)G and say what it gives.

G=
goals
match 1match 2
Daniel42
Farid35
Kumar16
ShowHide solution

(1×3)(3×2)(1 \times 3)(3 \times 2) gives 1×21 \times 2:

111
G
=
1 × 4 + 1 × 3 + 1 × 11 × 2 + 1 × 5 + 1 × 6
=
813

Multiplying by 1 changes nothing, so a row of ones adds the elements of each column: the three players scored 8 goals in match 1 and 13 goals in match 2.

The goals the three players scored in each match: 8 in match 1, 13 in match 2.

Question 6

Find NK and KN. What does multiplying by K do in each case?

N=
12
34
K=
01
10
ShowHide solution
NK=
1 × 0 + 2 × 11 × 1 + 2 × 0
3 × 0 + 4 × 13 × 1 + 4 × 0
=
21
43
KN=
0 × 1 + 1 × 30 × 2 + 1 × 4
1 × 1 + 0 × 31 × 2 + 0 × 4
=
34
12
NK≠KN

NK is N with its two columns swapped; KN is N with its two rows swapped. NK ≠ KN.

NK swaps the columns of N; KN swaps its rows.

NK=
21
43
KN=
34
12

Question 7

Find F2\mathbf{F}^2.

F=
12
03
ShowHide solution
F2=
12
03
12
03
=
1 × 1 + 2 × 01 × 2 + 2 × 3
0 × 1 + 3 × 00 × 2 + 3 × 3
=
18
09

Row 1, column 2 is 1×2+2×3=81 \times 2 + 2 \times 3 = 8, not 22=42^2 = 4.

Row by column:

F2=
18
09

Question 8

Find xx.

x1
23
2
5
=
13
19
ShowHide solution
x1
23
2
5
=
x × 2 + 1 × 5
2 × 2 + 3 × 5
=
2x + 5
19
=
13
19

Row 1: 2x+5=132x + 5 = 13, so 2x=82x = 8 and x=4x = 4. Row 2 has no unknown: 4+15=194 + 15 = 19, which agrees.

x=4x = 4

Question 9

Find the possible values of xx.

x3
x
4
=
16
ShowHide solution
x3
x
4
=
x × x + 3 × 4
=
x2 + 12
=
16

x2+12=16x^2 + 12 = 16, so x2=4x^2 = 4 and x=2x = 2 or x=−2x = -2.

Both work: 2×2+3×4=162 \times 2 + 3 \times 4 = 16 and (−2)×(−2)+3×4=16.(-2) \times (-2) + 3 \times 4 = 16\text{.} Keep both.

x=2x = 2 or x=−2x = -2

Question 10

True or false: "If AB can be found, then BA can be found." Use the matrices A and B below to decide.

A=
120
013
B=
1
2
1
ShowHide solution

AB is (2×3)(3×1)(2 \times 3)(3 \times 1): it can be found, and is 2×12 \times 1.

AB=
1 × 1 + 2 × 2 + 0 × 1
0 × 1 + 1 × 2 + 3 × 1
=
1 + 4 + 0
0 + 2 + 3
=
5
5

BA is (3×1)(2×3)(3 \times 1)(2 \times 3):

BAcannot be found: (3 × 1)(2 × 3), the first has 1 column but the second has 2 rows.

False: here AB can be found but BA cannot.

Question 11

With A and B from Example 3: (a) Hui Min works out AB by multiplying corresponding elements, and gets 8, 0 in row 1 and −6, −5 in row 2. (b) Amir finds the square of the matrix M below by squaring each element. Explain each mistake and give the right answers.

M=
2−1
10
ShowHide solution

(a) A product is not found element by element: each element of AB is a row of A times a column of B. The right answer is Example 3's:

AB=
65
14−5

(b) M2\mathbf{M}^2 means MM, row by column:

M2=
2−1
10
2−1
10
=
2 × 2 + (−1) × 12 × (−1) + (−1) × 0
1 × 2 + 0 × 11 × (−1) + 0 × 0
=
3−2
2−1

Amir's answer, 4, 1 in row 1 and 1, 0 in row 2, is the elements squared, which is not M2\mathbf{M}^2.

(a) AB is rows times columns. (b) M2=MM\mathbf{M}^2 = \mathbf{MM}:

AB=
65
14−5
M2=
3−2
2−1

Question 12

At the food stall (mee rebus $4, nasi lemak $3, mee soto $5), Aisyah buys 2 plates of mee rebus and 1 of nasi lemak, and Ben buys 1 mee rebus, 2 nasi lemak and 1 mee soto. Write what they buy as a 2×32 \times 3 matrix R and the prices as a column matrix C, and use a product to find what each of them pays.

ShowHide solution

Rows of R: Aisyah, Ben; columns: the three dishes, in the same sequence as the rows of C.

R=
mee rebusnasi lemakmee soto
Aisyah210
Ben121
C=
4
3
5
RC=
2 × 4 + 1 × 3 + 0 × 5
1 × 4 + 2 × 3 + 1 × 5
=
8 + 3 + 0
4 + 6 + 5
=
11
15

Aisyah pays $11 and Ben $15.

Aisyah $11, Ben $15

Key Points

  • A row times a column: multiply in pairs and add. The row and the column must have the same number of elements.
  • A product can be found only when the columns of the first equal the rows of the second: (2×3)(3×2)(2 \times 3)(3 \times 2), inner numbers equal; the outer numbers give the order, 2×22 \times 2.
  • The element in row 2, column 1 of AB is row 2 of A times column 1 of B.
  • In general AB ≠ BA: keep the matrices the way round they are written.
  • A2=AA\mathbf{A}^2 = \mathbf{AA}, for a square matrix only; never square each element.
  • For unknowns, multiply out, equate corresponding elements, and solve.

Previous lesson4.3 Multiplying a Matrix by a Number Next lesson4.5 Problems with Matrices

All Secondary 4 (Grade 10) lessons

Home Campus has lessons for Primary 3 to Secondary 4, and practice questions with worked solutions and worksheets for Primary 3 to Secondary 2. Register free to practise and keep track of progress.

This lesson follows the Singapore Secondary 4 syllabus and was checked question by question before it was published. Spotted a mistake? Tell us.