136 CHAPTER 8. MATRICES
8.4 Multiplication of MatricesSay you have A an m×n matrix and B an n× p matrix. We want to define an m× p matrixcalled AB such that
(AB)x= A(Bx) (8.10)
In other words, we want the linear transformation determined by AB to be the same asfirst doing a linear transformation determined by B and then when this has been done,do the linear transformation determined by A to what you got. In short, we want matrixmultiplication to correspond to composition of linear functions. Then 8.10 is satisfied ifand only if
((AB)x)i ≡ ∑l(AB)il xl = (A(Bx))i = ∑
kAik (Bx)k
= ∑k
Aik ∑l
Bklxl = ∑k
∑l
AikBklxl = ∑l
(∑k
AikBkl
)xl
If this is to hold for all choices of x, then it must also hold for x= er. Thus the ith entryof the rth column is (AB)er and using this, we obtain
(AB)ir = ∑l
(∑k
AikBkl
)(er)l = ∑
kAikBkr
Thus if we have the requirement that matrix multiplication corresponds to composition ofthe corresponding linear transformations, we are forced to conclude the following definitionfor matrix multiplication.
Definition 8.4.1 Let A be m× n and B be n× p. Then AB is m× p and the irth entry of(AB) is given by
(AB)ir ≡∑k
AikBkr
That is, the irth entry is the dot product of the ith row of A with the jth column of B.
Note that from this definition, you must have the number of columns of A equal tothe number of rows of B in order to make any sense of the product. Indeed, this must beso when you consider matrix multiplication in terms of linear transformations. A lineartransformation T : Fn→ Fm is only defined on vectors in Fn.
For A and B matrices, in order to form the product, AB the number of columns of Amust equal the number of rows of B.
(m×these must match!
n̂) (n× p ) = m× p
Note the two outside numbers give the size of the product. Remember:
If the two middle numbers don’t match, you can’t multiply the matrices!
Example 8.4.2 Let
A =
(1 −1 23 −2 1
), B =
2 3−1 10 3
Then find AB. After this, find BA