Multiplying matrices · Mathematics Class 11–12 | StemPy Lab
Course 8.1·Lesson 2 of 3
Multiplying matrices
The product AB exists when the number of columns of A equals the number of rows of B. Each entry of AB is a row of A multiplied entry by entry with a column of B
about 30 min1 simulation1 practice question1 Python program5 questions to check yourself
This lesson is free to read. Enroll free to keep your place and take the tests.
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
decide whether a product exists and find the order of the answer;
multiply two matrices, entry by entry, by the row-by-column rule;
state which rules of number arithmetic hold for matrices and which fail;
use a product to follow two moves of a shape, or to count routes in a network.
When can two matrices be multiplied?
Multiplying matrices is not entry by entry. It combines a row of the first matrix with a column of the second. For that, the row and the column must have the same length.
The product AB exists when the number of columns of A equals the number of rows of B. If A has order m×n and B has order n×p, then AB has order m×p. The two inner numbers must match, and the two outer numbers give the order.
The row-by-column rule
The entry of AB in row i and column j is row i of A times column j of B. Multiply the first entries, the second entries and so on, then add:
(AB)ij=ai1b1j+ai2b2j+⋯+ainbnj.
Take $A =
[1324]
andB =
[0512]
$.
AB=[1⋅0+2⋅53⋅0+4⋅51⋅1+2⋅23⋅1+4⋅2]=[1020511].
Now multiply in the other order.
BA=[0⋅1+1⋅35⋅1+2⋅30⋅2+1⋅45⋅2+2⋅4]=[311418].
So AB=BA. For numbers, 3×5=5×3 always. For matrices the order of the factors matters.
Rectangular matrices
Let C be 2×3 and D be 3×2:
C=[130121],D=210103.
The inner numbers are both 3, so CD exists and has order 2×2. It is
CD=[2776].
The product DC also exists, but it has order 3×3. Here the two products do not even have the same order. If A is 2×3 and B is 4×2, then BA exists but AB does not.
What stays the same
These rules of arithmetic still hold, whenever the products and sums exist:
(AB)C=A(BC), so we may write ABC;
A(B+C)=AB+AC and (A+B)C=AC+BC;
k(AB)=(kA)B=A(kB);
AI=IA=A for the identity matrix I of the right order, and AO=OA=O.
What changes
No commutative law. In general AB=BA.
Zero products.AB=O can happen when neither A nor B is O. For example $
[2142]
[2−1−42]
= O$.
No cancelling.AB=AC does not mean B=C.
Identities with squares change.(A+B)2=A2+AB+BA+B2, which equals A2+2AB+B2 only when AB=BA.
Why multiplication is defined this way
Think of a matrix as a move of the plane. The matrix B takes a point v to Bv. Then A takes that point to A(Bv). The product AB is the single matrix that does both moves, right factor first. If you turn and then stretch, you do not get what you get by stretching and then turning, so AB=BA.
Two panels show the same arrow shape, a right-angled triangle with corners (0, 0), (2, 0) and (0, 1). In the left panel it is first reflected in the x-axis and then rotated 90 degrees anticlockwise, and the final triangle has corners (0, 0), (0, 2) and (1, 0), pointing up and to the right. In the right panel the order is reversed: rotate first, then reflect. The final triangle has corners (0, 0), (0, -2) and (-1, 0), pointing down and to the left. The titles say that R times F and F times R give different pictures.
Let $R =
[01−10]
turntheplane90^\circanticlockwiseandletF =
[100−1]
reflectitinthex−axis.ThenRF =
[0110]
isthereflectionintheliney = x,andFR =
[0−1−10]
isthereflectionintheliney = -x$. Computer graphics, A-Level Further Maths and IB all use matrices like this to move points.
Counting routes
A matrix of 0s and 1s can describe a network. Let the entry in row i and column j be 1 if there is a direct flight from city i to city j. For three cities with flights P→Q, P→R, Q→R and R→P,
N=001100110,N2=110001101.
The entry of N2 in row i and column j counts the routes from city i to city j with exactly two flights. The entry of Nk counts the routes with exactly k flights.
A worked example
Find AB and BA for $A =
[23−10]
andB =
[1−245]
bylookingonlyattheentryinrow1,column2$ of each.
For AB. Row 1 of A is (2,−1). Column 2 of B is (4,5). The entry is 2×4+(−1)×5=3.
For BA. Row 1 of B is (1,4). Column 2 of A is (−1,0). The entry is 1×(−1)+4×0=−1.
Compare. The entries are 3 and −1, so AB=BA.
Practise with new numbers
Try it in Python
The program multiplies two matrices with two loops, using the row-by-column rule. Then it checks the answer against the @ operator and compares AB with BA.
Common mistakes
Multiplying entry by entry. The product is row by column, not place by place.
Assuming AB=BA. Always keep the factors in the order given.
Using (A+B)2=A2+2AB+B2. It needs AB=BA.
Cancelling a matrix. From AB=AC you may not conclude B=C.
Forgetting to check the orders. Check that the inner numbers match before you start.
Remember these
A is m×n and B is n×p: then AB is m×p.
(AB)ij is row i of A times column j of B.
Associative and distributive laws hold. The commutative law does not.
AB=O does not force A=O or B=O.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
A is 2×3 and B is 3×4. Does AB exist? Does BA exist?
Find $
[1021]
[34]
$.
[3+80+4]
=
[114]
$.
Is (A−B)(A+B)=A2−B2 for every pair of square matrices?
Let $A =
[1011]
.FindA²andA³,andguessA^n$.
[1021]
andA³ =
[1031]
.ThepatternisA^n =
[10n1]
$.
What is AI if A is any 3×3 matrix and I is the identity of order 3?
References
NCERT, Mathematics Textbook for Class XII, Part I, Chapter 3 (Matrices), the section on multiplication of matrices.
OpenStax, Precalculus 2e, Section 9.5 (Matrices and Matrix Operations).
Enroll free in Matrices and Matrix Algebra
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.