1. Introduction

In the module Introduction to Matrices, the basic rules of addition and subtraction of matrices, as well as scalar multiplication, were introduced. The rule for the multiplication of two matrices is the subject of this module. The first example is the simplest.

Recall that if M is a matrix then the transpose of M, written MT, is the matrix obtained from M by writing the rows of M as the columns of MT.

If A = (a1 a2 ... an) is a 1 × n (row) matrix and B = (b1 b2 ... bn)T is a n × 1 (column) matrix, then the product AB is defined as:

AB = (a1 a2 ... an)

 b1 b2 ... bn

= a1b1 + a2b2 + ... + anbn

This general rule is sometimes called the inner product.

N.B. The row matrix is on the left and the column matrix is on the right in the example above.

Example 1: For each of the following cases, find the product AB.

(a) A = (1 2), B = (4 3)T

Solution:

AB = (1 2)

 4 3

= 1 × 4 + 2 × 3 = 4 + 6 = 10

(b) A = (1 1 1), B = (2 3 4)T

Solution:

AB = (1 1 1)

 2 3 4

= 1 × 2 + 1 × 3 + 1 × 4 = 2 + 3 + 4 = 9

(c) A = (1 −1 2 3), B = (1 1 −3 2)T

Solution:

AB = (1 −1 2 3)

 1 1 −3 2

= 1 × 1 + (−1) × 1 + 2 × (−3) + 3 × 2 = 1 + (−1) + (−6) + 6 = 0

Exercise 1: For each of the cases below, calculate AB.

(a) A = (−2 4), B = (3 2)T

Solution: If the row matrix A = (−2 4) and the column matrix

B =

 3 2

are multiplied, the resulting inner product is:

AB = (−2 4)

 3 2

= −2 × 3 + 4 × 2 = −6 + 8 = 2
(b) A = (5 3 −2), B = (3 −4 2)T

Solution: If the row matrix A = (5 3 −2) and the column matrix

B =

 3 −4 2

are multiplied, the resulting inner product is:

AB = (5 3 −2)

 3 −4 2

= 5 × 3 + 3 × (−4) + (−2) × 2 = 15 − 12 − 4 = −1
(c) A = (4 4 −2 −3), B = (5 −4 3 −2)T

Solution: If the row matrix A = (4 4 −2 −3) and the column matrix

B =

 5 −4 3 −2

are multiplied, the resulting inner product is:

AB = (4 4 −2 −3)

 5 −4 3 −2

= 4 × 5 + 4 × (−4) + (−2) × 3 + (−3) × (−2) = 20 −16 −6 + 6 = 4

Click on questions to reveal their solutions

The following observations are worth noting:

• The row matrix is on the left, the column matrix is on the right.
• The row and column have the same number of elements.
• The inner product AB is a 1 × 1 matrix, i.e. a number.
• Nothing yet has been said about the matrix product BA.

Quiz 1: If A = (x x 1) and B = (x 6 9)T, which of the following values of x will result in AB = 0?

(a) x = 1 Incorrect - please try again!
(b) x = 3 Incorrect - please try again!
(c) x = −3 Correct - well done!
(d) x = −2 Incorrect - please try again!

Explanation: Multiplying the row matrix A = (x x 1) with the column matrix

B =

 x 6 9

are multiplied, the resulting inner product is:

AB = (x x 1)

 x 6 9

= x × x + x × 6 + 1 × 9
= x2 + 6x + 9 = (x + 3)2

Therefore the inner product AB = 0 when x = −3.

2. Matrix Multiplication 1

The previous section gave the rule for the multiplication of a row vector A with a column vector B, the inner product AB. This section will extend the idea to more general matrices. Suppose that

A =

 a1 a2 ... an c1 c2 ... cn

and B = (b1 b2 ... bn)T. Then:

AB =

 a1 a2 ... an c1 c2 ... cn

 b1 b2 ... bn

=

 a1b1 + a2b2 + ... + anbn c1b1 + c2b2 + ... + cnbn

Example 2: Find AB for both of the following cases:

(a)

A =

 1 2 3 −1

, B = (4 3)T

Solution:

AB =

 1 2 3 −1

 4 3

=

 1×4 + 2×3 3×4 + (−1)×3

=

 10 9

(b)

A =

 1 1 1 −2 1 −3

, B = (2 3 4)T

Solution:

AB =

 1 1 1 −2 1 −3

 2 3 4

=

 1×2 + 1×3 + 1×4 (−2)×2 + 1×3 + (−3)×4

=

 9 −13

The following observations on AB are worth noting:

• The element in the first row of AB is the inner product of the first row of A with the column matrix B.
• The element in the second row of AB is the inner product of the second row of A with the column matrix B.
• The number of columns of A must be equal to the number of rows of B.
• If A is 2 × n and B is n × 1, then AB is 2 × 1.

This rule for multiplication may be extended to matrices, A, which have more than two rows. For example, if A had 3 rows then the resulting matrix, AB, would have a third row; the value of this element would be the inner product of the third row of A with the column matrix B.

Exercise 2: For each of the cases below, calculate AB:

(a)
A =

 −2 4 5 3

, B = (4 3)T

Solution: For the 2 × 2 matrix

A =

 −2 4 5 3

and the column B = (4 3)T, the product AB

AB =

 −2 4 5 3

 4 3

=

 (−2) × 4 + 4 × 3 5 × 4 + 3 × 3

=

 4 29

(b)
A =

 5 3 2 4 −1 −1

, B = (2 3 4)T

Solution: If the 2 × 3 matrix

A =

 5 3 2 4 −1 −1

and the column matrix B = (2 3 4)T are multiplied together, the resulting product AB is:

AB =

 5 3 2 4 −1 −1

 2 3 4

=

 5 × 2 + 3 × 3 + 2 × 4 4 × 2 + (−1) × 3 + (−1) × 4

=

 27 1

(c)
A =

 −2 4 5 3 4 −1

, B = (4 3)T

Solution: If the 3 × 2 matrix is

A =

 −2 4 5 3 4 −1

and the column matrix is B = (4 3)T, then the product AB is

AB =

 −2 4 5 3 4 −1

 4 3

=

 (−2) × 4 + 4 × 3 5 × 4 + 3 × 3 4 × 4 + (−1) × 3

=

 4 29 13

(d)
A =

 4 4 −2 −3 3 −1 −1 2

, B = (5 −4 3 2)T

Solution: If the 2 × 3 matrix

A =

 4 4 −2 −3 3 −1 −1 2

is multiplied with the column matrix B = (5 −4 3 2)T, the resulting product, AB is

AB =

 4 4 −2 −3 3 −1 −1 2

 5 −4 3 2

=

 4 × 5 + 4 × (−4) + (−2) × 3 + (−3) × 2 3 × 5 + (−1) × (−4) + (−1) × 3 + 2 × 2

=

 −8 20

Click on questions to reveal their solutions

3. Matrix Multiplication 2

The extension of the concept of matrix multiplication to matrices A, B, in which A has more than one row and B has more than one column is now possible. The product matrix AB will have the same number of columns as B and each column is obtained by taking the product of A with each column of B, in turn, as shown below:

Let A =

 4 1 2 3 −1 2

and B =

 2 −1 3 2

and let b1, b2 be the first and second columns of B respectively. Then
Ab1 =

 4 1 2 3 −1 2

 2 3

=

 11 13 4

and Ab2 =

 4 1 2 3 −1 2

 −1 2

=

 −2 4 5

Thus:

AB =

 4 1 2 3 −1 2

 2 −1 3 2

=

 11 −2 13 4 4 5

Exercise 3: For each of the cases below, calculate AB.

(a)
A =

 −2 4 5 3

, B =

 −2 4 5 3

Solution: Let A and B be the 2 × 2 matrices

A =

 −2 4 5 3

and B =

 −2 4 5 3

The matrix AB is

AB =

 −2 4 5 3

 −2 4 5 3

=

 (−2) × (−2) + 4 × 5 (−2) × 4 + 4 × 3 5 × (−2) + 3 × 5 5 × 4 + 3 × 3

=

 24 4 5 29

(b)
A =

 3 2 7 5

, B =

 5 −2 −7 5

Solution: If A and B are the 2 × 2 matrices

A =

 3 2 7 5

and B =

 5 −2 −7 3

The matrix AB is

AB =

 3 2 7 5

 5 −2 −7 3

=

 3 × 5 + 2 × (−7) 3 × (−2) + 2 × 3 7 × 5 + 5 × (−7) 7 × (−2) + 5 × 3

=

 1 0 0 1

This is called the 2 × 2 identity matrix.

(c)
A =

 −2 4 5 3 4 −1

, B =

 −2 4 5 3

Solution: If A and B are the matrices

A =

 −2 4 5 3 4 −1

and B =

 −2 4 5 3

then the matrix AB is

AB =

 −2 4 5 3 4 −1

 −2 4 5 3

=

 (−2) × (−2) + 4 × 5 (−2) × 4 + 4 × 3 5 × (−2) + 3 × 5 5 × 4 + 3 × 3 4 × (−2) + (−1) × 5 4 × 4 + (−1) × 3

=

 24 4 5 29 −13 13

(d)
A =

 5 3 2 4 −1 −1

, B =

 −2 4 5 3 4 −1

Solution: If A is 2 × 3 and B is 3 × 2, given by the following

A =

 5 3 2 4 −1 −1

and B =

 −2 4 5 3 4 −1

The matrix AB is

AB =

 5 3 2 4 −1 −1

 −2 4 5 3 4 −1

=

 5 × (−2) + 3 × 5 + 2 × 4 5 × 4 + 3 × 3 + 2 × (−1) 4 × (−2) + (−1) × 5 + (−1) × 4 4 × 4 + (−1) × 3 + (−1) × (−1)

=

 13 27 −17 14

Click on questions to reveal their solutions

The rules for finding the product of two matrices are summarised here:

• If A is m × n and B is n × r then the product AB exists.
• The resulting matrix is m × r ((m × n)(n × r) → m × r)
• The element in the ith row, jth column of the matrix AB is the inner product of the ith row of A with the jth column of B.

Example 3: Find the element in the 2nd row, 3rd column of AB if

A =

 1 2 −1 3

and B =

 1 4 −2 3 −1 2

Solution: Since A is 2 × 2 and B is 2 × 3, the product AB exists and is a 2 × 3 matrix. The required element is the inner product of the second row of A with the third column of B, i.e.

(−1) × (−2) + 3 × 2 = 2 + 6 = 8

Exercise 4: If

A =

 1 −2 4 5 7 −8 −6 2 2 3 −1 −2

and B =

 −2 1 −3 0 −2 −5 4 −3 7 0 0 6

find the ijth element, i.e. the element in the ith row and jth column, of AB for the following cases:

(a) i = 3, j = 2

Solution: The (3 2) element in the matrix AB, AB32, is the inner product of the third row of A with the second column of B, i.e.

 AB32 = 2 × 1 + 3 × (−2) + (−1) × (−3) + (−2) × 0 = 2 − 6 + 3 + 0 = −1
(b) i = 2, j = 3

Solution: The (2 3) element in the matrix AB, AB23, is the inner product of the second row of A with the third column of B, i.e.

 AB23 = 7 × (−3) + (−8) × (−5) + (−6) × (−7) + 2 × 6 = −21 + 40 + 42 + 12 = 73
(c) i = 1, j = 2

Solution: The (1 2) element in the matrix AB, AB12, is the inner product of the first row of A with the second column of B, i.e.

 AB12 = 1 × 1 + (−2) × (−2) + 4 × (−3) + 5 × 0 = 1 + 4 − 12 + 0 = −7
(d) i = 2, j = 1

Solution: The (2 1) element in the matrix AB, AB21, is the inner product of the second row of A with the first column of B, i.e.

 AB21 = 7 × (−2) + (−8) × 0 + (−6) × 4 + 2 × 0 = −14 + 0 − 24 + 0 = −38
(e) i = 3, j = 1

Solution: The (3 1) element in the matrix AB, AB31, is the inner product of the third row of A with the first column of B, i.e.

 AB31 = 2 × (−2) + 3 × 0 + (−1) × 4 + (−2) × 0 = −4 + 0 − 4 + 0 = −8
(f) i = 1, j = 3

Solution: The (1 3) element in the matrix AB, AB13, is the inner product of the second row of A with the first column of B, i.e.

 AB13 = 1 × (−3) + (−2) × (−5) + 4 × (−7) + 5 × 6 = −3 + 10 − 28 + 30 = 9

Click on questions to reveal their solutions

Quiz 2: Which of the following is the element in the third row, third column, of the matrix AB in Exercise 4?

(a) 26 Incorrect - please try again!
(b) −26 Correct - well done!
(c) −12 Incorrect - please try again!
(d) 12 Incorrect - please try again!

Explanation: The (3 3) element in the matrix AB, AB3 3, is the inner product of the third row of A with the third column of B, i.e.

 AB3 3 = 2 × (−3) + 3 × (−5) + (−1) × (−7) + (−2) × 6 = −6 − 15 + 7 − 12 = −26

4. The Identity Matrix

If A and B are two matrices, the product AB can be found if the numbers of columns of A equals the numbers of rows of B. If A is 2 × 3 and B is 3 × 5 then AB can be calculated but BA does not exist. The order in which matrices are multiplied together matters. Even when AB and BA both exist it is usually the case that ABBA.

There is one particular matrix, the identity matrix, which has very specific multiplication properties. The n× n identity matrix is the n × n matrix with 1s of 0s as shown in the following example.

Example 4: The 2 × 2, 3 × 3 and 4 × 4 identity matrices are

 1 0 0 1

,

 1 0 0 0 1 0 0 0 1

,

 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

The most important property of the identity matrix is revealed in the following exercise:

Exercise 5: If the identity matrix is denoted by I and the matrix M is:

M =

 1 2 4 7 8 6

use the appropriate identity matrix to calculate the following matrix products:

(a) IM, where I is the 2 × 2 identity matrix.

Solution: For the 2 × 3 identity M, the left identity matrix (multiplying M on the left to obain MI) is the 2 × 2 matrix I:

I =

 1 0 0 1

The product IM is then:

IM =

 1 0 0 1

 1 2 4 7 8 6

=

 1 × 1 + 0 × 7 1 × 2 + 0 × 8 1 × 4 + 0 × 6 0 × 1 + 1 × 7 0 × 2 + 1 × 8 0 × 4 + 1 × 6

=

 1 2 4 7 8 6

= M
(b) MI, where I is the 3 × 3 identity matrix.

Solution: For the 2 × 3 matrix M, the right identity matrix (multiplying M on the right to obain IM) is the 3 × 3 matrix I:

I =

 1 0 0 0 1 0 0 0 1

The product IM is then

IM =

 1 2 4 7 8 6

 1 0 0 0 1 0 0 0 1

=

 1 × 1 + 2 × 0 + 4 × 0 1 × 0 + 2 × 1 + 4 × 0 1 × 0 + 2 × 0 + 4 × 1 7 × 1 + 8 × 0 + 6 × 0 7 × 0 + 8 × 1 + 6 × 0 7 × 0 + 8 × 0 + 6 × 1

=

 1 2 4 7 8 6

= M

Click on questions to reveal their solutions

In matrix multiplication, the identity matrix, I, behaves exactly like the number 1 in ordinary multiplication. This was seen in the previous exercise. For part (a), the matrix I is the 2 × 2 identity matrix; in part (b), I was 3 × 3, they satisfy the equation IM = M = MI.

Example 5: Calculate AB and BA for the matrices:

A =

 4 3 2 5 6 3 3 5 2

and B =

 3 −4 3 1 −2 2 −7 11 −9

Solution: Using the rules of matrix multiplication

AB =

 4 3 2 5 6 3 3 5 2

 3 −4 3 1 −2 2 −7 11 −9

=

 1 0 0 0 1 0 0 0 1

= I
BA =

 3 −4 3 1 −2 2 −7 11 −9

 4 3 2 5 6 3 3 5 2

=

 1 0 0 0 1 0 0 0 1

= I

The matrix B is the inverse of the matrix A, and this is usually written as A−1. Equally, the matrix A is the inverse of B. The equation AA−1 = A−1A = I is always true.

5. Quiz on Matrix Multiplication

Let: A =

 1 1 1 o 2 1 1 0 1

, B =

 2 −1 −1 1 0 1 −2 1 2

, C =

 3 1 4 2 1 3 2 2 1

Choose the correct option from the following

1.The (2 3) element of AB is :
(a) −1
(b) 1
(c) 0
(d) 2
2.The (3 1) element of CBis:
(a) 3
(b) −1
(c) 4
(d) −6
3.The (2 2) element of CAis:
(a) 4
(b) −3
(c) 0
(d) 2
4. Which of the following statements is true?
(a) B = C−1
(b) A = B−1
(c) C = A−1