When two matrices can be multiplied, how each entry of the product is a row-column dot product, why a product means doing one linear map after another, and why the order of the factors matters.
Two bakery shops sell muffins and loaves. One table records how many of each item each shop sold today, and another gives each item’s price and its cost to make. To get a shop’s revenue you multiply matching numbers and add, a row of one table against a column of the other. That rule is matrix multiplication, and the same rule describes what happens when you move the points of the plane with one matrix and then with another.
Key terms
Compatible dimensions
Definition Let A be an m×n matrix and B a p×q matrix. The product AB is defined exactly when n=p, that is, when A has as many columns as B has rows. In that case AB is an m×q matrix,
m×nAn×qB=m×qAB.
In plain words Write the two sizes side by side. The two inside numbers must match, and the two outside numbers give the size of the answer.
Example Let A be 2×3 and B be 3×4. The inside numbers are 3 and 3, so AB exists and is 2×4. In the other order the sizes read 3×4 and 2×3, the inside numbers 4 and 2 differ, and BA is not defined.
Order changes sizes too. A 1×3 row times a 3×1 column is a 1×1 matrix, a single number, while the column times the row is a 3×3 matrix.
Row-column dot product
Definition Let A=[aij] be m×n and B=[bij] be n×q. The product AB is the m×q matrix whose entry in row i and column j is
This is the dot product of row i of A with column j of B, both read as vectors with n components.
In plain words To fill the spot in row i and column j of the answer, run across row i of the first matrix and down column j of the second, multiply the pairs, and add.
Example In the matrix S the rows are the two shops and the columns are muffins and loaves sold. In P the rows are muffins and loaves and the columns are price and cost in dollars.
S=[30181220],P=[3512].
Row 1 of S against column 1 of P gives shop 1’s revenue, 30⋅3+12⋅5=150 dollars. All four spots together give
Shop 1 took in 150 dollars for goods that cost 54 dollars to make, and shop 2 took in 154 dollars for goods that cost 58.
A matrix as a map
Definition Write a vector with n real components as an n×1 column, so ⟨a,b⟩ becomes the column with entries a and b. The set of all such vectors is Rn, and a point stands for its position vector. An m×n matrix A defines the function x↦Ax from Rn to Rm, where Ax is the matrix product. This function is linear, meaning
A(u+v)A(cu)=Au+Avand=cAu
for all u and v in Rn and every real number c. Conversely, every linear map from Rn to Rm has this form for exactly one m×n matrix, the one whose column k is the image of ek, the vector with 1 in place k and 0 everywhere else. For maps the word linear has this stricter meaning. With one variable, x↦mx is a linear map, but a linear functionmx+b with b=0 is not, since it sends 0 to b.
In plain words A matrix is a rule that moves vectors. In the plane e1 and e2 are the standard unit vectors i and j, so the first column says where i lands and the second column says where j lands, and every other vector follows along.
Example The matrix below stretches the plane sideways by a factor of 2,
Its columns show that i goes to ⟨2,0⟩ and j stays put, so each unit square of the grid becomes a rectangle 2 wide and 1 tall.
Composition of linear maps
Definition Let A be m×n and B be n×p. For every x in Rp
A(Bx)=(AB)x.
So applying B first and then A is the same linear map as applying the single matrix AB. The matrix that acts first stands on the right. The same reasoning shows that multiplication is associative, (AB)C=A(BC) whenever the sizes fit.
In plain words Multiplying two matrices combines two moves into one. Read a product from right to left, because the right factor acts first.
Example Take the quarter turn counterclockwise B and the sideways stretch A from above,
BAAB=[01−10],=[2001],=[01−20].
Follow the point (1,1) in two stages. The turn sends it to (−1,1), and the stretch sends that to (−2,1). One step with the product gives the same point,
AB[11]=[0⋅1+(−2)⋅11⋅1+0⋅1]=[−21].
Noncommutativity
Definition Matrix multiplication is not commutative. The product AB can be defined while BA is not. When both are defined they can have different sizes, and for every n≥2 there are n×n matrices with AB=BA. Some pairs do commute, but that has to be checked, never assumed. Rules for numbers that rely on ab=ba can fail. For square matrices A and B of the same size
(A+B)2=A2+AB+BA+B2,
which equals A2+2AB+B2 only when AB=BA.
In plain words The order of the factors is part of the instruction. Turning and then stretching is usually not the same as stretching and then turning.
Example With the same A and B, stretch first and turn second,
This is not AB. The point (1,1) is stretched to (2,1) and then turned to (−1,2), while the other order gave (−2,1).
Identity matrix
Definition The n×n identity matrix In has every entry on the main diagonal, the entries in row i and column i, equal to 1 and every other entry equal to 0. For every m×n matrix A
ImA=AandAIn=A.
As a map, Inx=x for every x in Rn. In particular In commutes with every n×n matrix.
In plain words The identity matrix does for matrices what the number 1 does for numbers. It leaves every vector where it is.
Example Here are the two smallest identity matrices,
I2I3=[1001],=100010001.
For a 2×3 matrix A, row 1 of I2 has entries 1 and 0, and its dot product with any column of A simply picks out that column’s top entry. Row 2 picks out the bottom entry. So I2A=A, and in the same way AI3=A. The product I2A needs I2 and AI3 needs I3, because the sizes have to fit.
Zero matrix
Definition The m×n zero matrix O has every entry equal to 0. For every m×n matrix A we have A+O=A, and whenever the sizes fit, a product with a zero factor is a zero matrix, AO=O and OB=O. Unlike numbers, two nonzero matrices can have product O. So AB=O does not force A=O or B=O, and AB=AC does not force B=C.
In plain words The zero matrix sends every vector to the zero vector. Be careful, because a product can be zero even when neither factor is.
Example Neither factor below is zero, yet
[1111][1−1−11]=[1−11−1−1+1−1+1]=[0000].
The picture explains it. The right factor sends ⟨x,y⟩ to (x−y)⟨1,−1⟩, a multiple of ⟨1,−1⟩, and the left factor sends ⟨1,−1⟩ to 0.
Check yourself
The matrix A is 3×2 and B is 2×4. Which of AB and BA is defined, and what is its size?
Show the answer
The product AB is defined because the inside numbers 2 and 2 match, and it is 3×4. The product BA would pair 2×4 with 3×2, and 4=3, so it is not defined.
Compute AB and BA for the matrices below.
A=[1021],B=[1301]Show the answer
Row by column,
ABBA=[7321],=[1327].
For instance the top left entry of AB is 1⋅1+2⋅3=7, while the top left entry of BA is 1⋅1+0⋅0=1. The two products differ.
The matrix R below turns the plane a quarter turn counterclockwise. Compute R2=RR and describe the map it gives.
May we count page visits to understand which courses and learning features are useful? Cloudflare collects visit and performance statistics, without your account details or answers. Your choice does not affect access. Details