AB means do B first, then A; the product's columns are A applied to B's columns.
Yesterday each matrix moved the whole plane once. Today asks what happens when you do two moves in a row, and whether the result is still one matrix. The answer defines matrix multiplication, so the rule for multiplying matrices comes straight from the geometry instead of from a memorized recipe. Day 7 needs this product to say what it means to undo a matrix.
Each section below opens with a problem. Try it before you open the walkthrough, even if you only get partway. From here on, ^ and ^ mean the same green and red basis arrows that Day 5 called e1 and e2.
Composition
The shear S=[1011] acts on the plane first, and then the quarter turn R=[01−10] acts on the result. Where does x=[11] end up?
Walk through the solutionHide the walkthrough
We know how to apply one matrix at a time, so we do exactly that, starting with the move that happens first.
By Day 4's column picture, Sx is 1 times the first column of S plus 1 times the second column:
Sx=1[10]+1[11]=[21]
Now the quarter turn acts on (2,1), so we use the entries 2 and 1 as weights on the columns of R:
R[21]=2[01]+1[−10]=[−12]
The point ends at (−1,2). We wrote the whole trip as R(Sx), with S closest to x because it acts first.
Following one point works, but a second point would mean doing both multiplications again. Day 5 showed that a whole linear move is known once you know where ^ and ^ land, so the next problem follows just those two arrows.
Find a single matrix M that does "shear with S, then turn with R" in one step. Check it on x=(1,1).
Walk through the solutionHide the walkthrough
The columns of M must be the places where ^ and ^ end up after both moves, so we follow each arrow through S and then R.
1
The shear sends ^ to the first column of S, which is (1,0). The turn then sends (1,0) to the first column of R, which is (0,1). So the first column of M is (0,1).
2
The shear sends ^ to the second column of S, which is (1,1). The turn sends (1,1) to 1[01]+1[−10]=[−11]. So the second column of M is (−1,1).
3
Put the two columns side by side: M=[01−11].
4
Check on (1,1): M[11]=[01]+[−11]=[−12]. That matches the answer to Problem 1, so the single matrix really does both moves.
Each column of M came from sending a column of S through R. That pattern is the whole rule for multiplying matrices.
Two moves in a row are one matrix
The single matrix for "do B, then do A" is called the productAB. For the shear and the turn, RS=[01−11], and it satisfies
A(Bx)=(AB)xfor every x.
Read a product from right to left. The matrix next to x touches it first, so in RS the shear happens first.
The reason this works for every x is Day 4's column picture. Write B=[b1⋯bp]. Then
The second line uses the linearity of A from Day 5. Because a product is just "one move after another", grouping never matters: A(BC)=(AB)C, since both sides mean "do C, then B, then A". Doing the same move k times is written Ak, and A0=I. Powers come back with eigenvalues on Days 28 to 33.
Drag x below. The dashed arrows show the two hops, and the teal arrow is the single jump that RS makes.
Drag x so that applying S and then R carries it onto the ringed point [−13].
Right. RS[11]=[−13], so the single matrix RS does both steps at once.
Sx=[21]
R(Sx)=[−12]
RS=[01−11]
The column rule
Problem 2 found the product by sending each column of S through R. The next problem runs that recipe on two matrices with no picture attached, so you can see it is pure arithmetic.
Let A=[21−11] and B=[111−1]. Compute AB, entering it row by row.
Walk through the solutionHide the walkthrough
The columns of AB are A applied to the columns of B, so we compute two matrix–vector products.
The first column of B is (1,1). Its entries are the weights on the columns of A:
Ab1=1[21]+1[−11]=[12]
The second column of B is (1,−1):
Ab2=1[21]+(−1)[−11]=[30]
Stacking the two results as columns gives AB=[1230]. Each column of the answer is a combination of the columns of A, and the matching column of B supplies the weights.
Matrix product
If A is m×n and B is n×p with columns b1,…,bp, then the productAB is the m×p matrix
AB=A[b1⋯bp]=[Ab1⋯Abp].
Each column of AB is a combination of the columns of A, with weights from the matching column of B.
The picture below carries the grid through A. A column of B says how many green steps and how many red steps to take on that carried grid, so you can place each column of AB by counting.
Drag the yellow and blue dots to Ab1 and Ab2. Count steps along the blue grid that A carries.
Both columns are in place, so AB=[1230].
A=[21−11]
B=[111−1]
[Ab1Ab2]=?[111−1]
The column rule also runs backward. If you know A and a column of AB, you can recover the matching column of B by asking which weights on the columns of A produce it.
Let A=[112−1]. The first column of AB is [5−1]. Find the first column b1 of B.
Walk through the solutionHide the walkthrough
The first column of AB is Ab1. Call the entries of b1p and q. Then we need
p[11]+q[2−1]=[5−1].
Matching entries gives p+2q=5 and p−q=−1. Subtracting the second equation from the first removes p and leaves 3q=6, so q=2. Then p=−1+q=1.
So b1=(1,2). Check: 1(1,1)+2(2,−1)=(5,−1).
The first column of AB is the ringed point [5−1]. Set the two entries of b1 so that Ab1 lands on it.
Right. b1=[12], because 1a1+2a2 is the first column of AB.
A=[112−1]
Ab1=0[11]+0[2−1]=[00]
The row–column rule
The column rule builds a whole column at a time. Often you need only one entry, and there is a faster way to get it.
Let A=[1−324] and B=[2501−13]. Find only the entry of AB in row 2, column 3. Which numbers from A and B did you actually use?
Walk through the solutionHide the walkthrough
The entry in row 2, column 3 is the second entry of column 3, and column 3 of AB is Ab3 with b3=(−1,3):
Ab3=−1[1−3]+3[24]=[−1+63+12]=[515]
The entry we want is 15. Now look at how the 15 was made: (−3)(−1)+(4)(3). The numbers −3 and 4 are row 2 of A, and −1 and 3 are column 3 of B. Nothing else was needed.
Row times column gives one entry
To get the entry in row i and column j of AB, walk along row i of A and down column j of B together, multiply matching entries, and add:
(AB)ij=ai1b1j+ai2b2j+⋯+ainbnj.
For this to work, row i of A and column j of B must have the same length. So A needs as many columns as B has rows.
That length condition gives a quick size check. Write the sizes under the factors. In the figure, 2×2 times 2×3 has matching inner numbers, and the outer numbers say the answer is 2×3. The other order, BA, is 2×3 times 2×2, and the inner numbers 3 and 2 differ, so BA is not defined.
A is 3×5 and B is 5×2. Which statement is true?
The row–column rule also works for a whole row at once. Row i of AB uses only row i of A, so rowi(AB)=rowi(A)B. Here is row 2 of the product above, computed that way:
The row is a combination of the rows of B, with weights from row i of A. Day 8 uses this row version to show that every row operation from Day 3 is a multiplication by a matrix.
Order matters
Now turn first and shear second. Find the matrix for this order and enter it row by row. Then find where (1,1) lands, and compare with RS from Problem 2.
Walk through the solutionHide the walkthrough
The turn acts first, so the product is SR with R on the right. Its columns are S applied to the columns of R.
The first column of R is (0,1), and S(0,1)=0[10]+1[11]=[11].
The second column of R is (−1,0), and S(−1,0)=−1[10]+0[11]=[−10].
So SR=[11−10], and SR[11]=[11]+[−10]=[01].
In the other order, RS=[01−11] sent (1,1) to (−1,2). The same two moves in a different order put the same point in a different place.
Matrices usually do not commute
For most pairs of matrices, AB=BA. When AB=BA does hold, we say that A and Bcommute. The identity I commutes with every square matrix, because IA=A=AI.
Some pairs do commute. Slide k below until both orders move the unit square to the same place.
Slide k until AB and BA move the square to the same place.
At k=1 the two orders agree, so these two matrices commute. Every other k gives AB=BA.
A=[2011]B=[10k3]
AB=[2053]
BA=[2023]
Zero products
Ordinary numbers have a rule that if ab=0, then a=0 or b=0. The next problem tests whether that rule survives for matrices.
Let M=[1224]. Find a matrix B whose columns are both nonzero and different from each other, with MB=[0000].
Walk through the solutionHide the walkthrough
By the column rule, MB is zero exactly when M sends each column of B to 0. So we look for nonzero vectors (p,q) with M(p,q)=0.
p[12]+q[24]=[p+2q2p+4q]
Both entries are zero when p+2q=0, because the second entry is twice the first. Taking q=1 gives p=−2, and taking q=−2 gives p=4. So one answer is
BMB=[−214−2]=[−2+2−4+44−48−8]=[0000]
This worked because the columns of M lie on one line, so a combination of them can cancel to zero.
Drag the two columns of B to two different spots, neither of them the origin, so that M sends both of them to 0.
Now MB is the zero matrix, although neither M nor B is zero. Every column that works is a multiple of [−21].
M=[1224]
B=[1120]
MB=[3624]
Cancelling is not allowed
Two more rules from ordinary numbers fail for matrices.
AB=0 does not force A=0 or B=0. Problem 7 is an example.
AB=AC does not force B=C. In Problem 7, MB=M⋅0 even though B=0.
Both failures happen when A flattens the plane onto a line, so two different inputs can land on the same output. Day 7 names these matrices singular and shows that cancelling is safe for every other square matrix.
Matrix sums
Adding and scaling matrices works the way it did for vectors on Day 1, one entry at a time.
Let A=[10−243−1] and B=[2−31205]. Compute 3A−B, entering it row by row.
Walk through the solutionHide the walkthrough
Scale first, then subtract entry by entry. Tripling A gives [30−6129−3]. Subtracting B in each position:
[3−20−(−3)−6−112−29−0−3−5]=[13−7109−8]
Sums go entry by entry
The sumA+B adds matching entries, and the scalar multiplerA multiplies every entry by r. A sum is defined only when A and B have the same size, because every entry needs a partner. Sums and products mix the way numbers do, as long as you keep the order of each product: A(B+C)=AB+AC and (B+C)A=BA+CA.
The transpose
Take A=[1−324] and B=[2501−13] from Problem 5, where AB=[121424515]. Flip each matrix so its rows become its columns. Then multiply the flipped B by the flipped A and compare with the flipped AB.
Walk through the solutionHide the walkthrough
Flipping A turns its rows (1,2) and (−3,4) into columns, and flipping B does the same with its two rows of length 3:
AT=[12−34],BT=20−1513
BT is 3×2 and AT is 2×2, so BTAT is defined and is 3×2. Row by row with the row–column rule:
1
Row 1 of BT is (2,5). Pairing it with the columns of AT gives 2(1)+5(2)=12 and 2(−3)+5(4)=14.
2
Row 2 of BT is (0,1). It gives 0(1)+1(2)=2 and 0(−3)+1(4)=4.
3
Row 3 of BT is (−1,3). It gives −1(1)+3(2)=5 and −1(−3)+3(4)=15.
So BTAT=122514415, which is exactly AB flipped. The other order, ATBT, is 2×2 times 3×2, which is not even defined.
Transpose
The transposeAT of an m×n matrix A is the n×m matrix whose columns are the rows of A. Whenever AB is defined,
(AB)T=BTAT.
The order reverses for a reason you can see in Problem 9. Entry (i,j) of (AB)T is entry (j,i) of AB, which is row j of A paired with column i of B. Row i of BT is column i of B, and column j of AT is row j of A, so BTAT pairs the same two lists. On Day 16 the transpose lets you study the rows of A as the columns of AT, and from Day 34 on it carries symmetric matrices, dot products and least squares.
A is 2×3 and B is 3×4. Which product is defined?
Practice
Warm-up
A is 4×6 and AB is 4×2. What size is B? (Modeled on Lay §2.1 #7.)
Show the solutionHide the solution
For AB to be defined, B needs as many rows as A has columns, which is 6. The product has as many columns as B, and the product has 2 columns. So B is 6×2.
Compute 2[30−12]−[1−245], entering it row by row.
Show the solutionHide the solution
[60−24]−[1−245]=[52−6−1]
Write the transpose of [12−430−5], row by row.
Show the solutionHide the solution
The two rows become the two columns, so the transpose is 3×2:
1−4023−5
Core
Let A=[21−13] and B=[140−121]. Find the third column of AB. (Modeled on Lay §2.1 #5.)
Show a hintHide the hint
The third column of AB is A times the third column of B. Use its entries as weights on the columns of A.
Show the solutionHide the solution
The third column of AB is Ab3, a combination of the columns of A with weights 2 and 1:
Ab3=2[21]+1[−13]=[35]
The whole product is AB=[−2131−335]. The product BA is not defined, because B has 3 columns and A has 2 rows.
Let A=[30−241−1] and B=25−11−36. Use the row–column rule to find (AB)12 and (AB)21. (Modeled on Lay §2.1, Example 5.)
Show a hintHide the hint
(AB)12 pairs row 1 of A with column 2 of B. (AB)21 pairs row 2 of A with column 1 of B.
Let A=[1235]. The first column of AB is [47]. Find the first column of B. (Modeled on Lay §2.1 #17.)
Show a hintHide the hint
The first column of AB is Ab1. Write b1=(p,q) and match entries to get two equations.
Show the solutionHide the solution
We need p[12]+q[35]=[47], which means p+3q=4 and 2p+5q=7. Doubling the first equation gives 2p+6q=8. Subtracting the second equation leaves q=1, and then p=4−3=1. So b1=(1,1).
Check: 1(1,2)+1(3,5)=(4,7).
Let A=[1−2−24], B=[3112] and C=[1054]. Compute AB and AC, entering AB row by row. Why can the two products agree when B=C? (Modeled on Lay §2.1 #10.)
Show a hintHide the hint
Look at B−C. What does A do to each of its columns?
The difference is B−C=[21−4−2], and both of its columns are multiples of (2,1). Since A(2,1)=2(1,−2)+1(−2,4)=(0,0), we get A(B−C)=0, which means AB=AC. The columns of A lie on one line, so A cannot tell B and C apart, and you cannot cancel A.
Tomorrow, on Day 7, you ask whether a move can be undone, which means looking for a matrix A−1 whose product with A is the identity.