4.10 - Matrices
Overview
A matrix is a rectangular array of numbers. Matrices organize data, like sales by store and by product, and starting in Topic 4.12 they describe transformations of the plane. This topic covers how to describe a matrix's size and how to multiply two matrices. Matrix multiplication is built entirely out of the dot product from Topic 4.8.
What a matrix is
An matrix (read "n by m") is an array with rows and columns. Rows run across and columns run down. The number of rows always comes first.
- Entries: the number in row and column is called the entry, written . In above, (row 2, column 3).
- Square matrix: a matrix with the same number of rows and columns, like a matrix.
- Row and column vectors: a matrix is a single row, and an matrix is a single column. The vector is often written as the column , which is how matrices act on vectors in Topic 4.12.
When can you multiply?
Two matrices can be multiplied only if the number of columns in the first matrix equals the number of rows in the second. Write the dimensions side by side:

- The inside numbers have to match.
- The outside numbers give the size of the product.
So a matrix times a matrix is a matrix, but a matrix times another matrix isn't defined.
How to multiply
The product is a new matrix. The entry in row and column of is the dot product of row of and column of : multiply matching entries and add.
That's why the inside dimensions have to match. A row of has as many entries as has columns, a column of has as many entries as has rows, and a dot product needs the same number of entries on each side.

Example 1: Which products exist?
is , is , is , and is . Which of , , , , , and are defined, and what size is each one?
Product | Dimensions | Inside numbers match? | Size of product |
yes | |||
yes | |||
no, | not defined | ||
yes | |||
yes | |||
no, | not defined |
Answer: (), (), (), and () are defined, and and aren't. Notice that and are both defined but aren't even the same size.
Example 2: Multiplying matrices
Let and . Find and .
Step 1: Find . It's , and each entry is a row of dotted with a column of :
- Row 1, column 1:
- Row 1, column 2:
- Row 2, column 1:
- Row 2, column 2:
Step 2: Find . Now use rows of and columns of :
Answer: and . They're different. Order matters in matrix multiplication: in general, .
Example 3: Matrices of different sizes
Find for and .
Step 1: Size. works, and is .
Step 2: Entries. Each one is a row of (3 entries) dotted with a column of (3 entries):
- Row 1, column 1:
- Row 1, column 2:
- Row 2, column 1:
- Row 2, column 2:
The row 2, column 1 entry is the one shown in the figure above. Multiplying in the other order gives a matrix:
Answer: . Here and can't be equal, since they aren't even the same size.
A matrix times a vector
A matrix times a column vector () gives another column vector (). It's the same rule, row times column:
The matrix turned the vector into the vector . Topic 4.12 builds on exactly this idea: a matrix as a function that transforms vectors.
Example 4: Coffee shop sales
A coffee shop has two locations. Matrix gives one day's sales, with rows for the Downtown and Campus locations and columns for lattes, teas, and cold brews. Matrix gives each drink's price and its cost to make, in dollars, with rows for latte, tea, and cold brew and columns for price and cost. (The numbers are made up for practice.)
(a) Find and explain what each entry means. (b) Which location made more profit that day, and by how much? (c) is also defined. Does it mean anything?
(a) is and is , so is . The inside number, 3, counts the drinks, so each dot product adds up over the three drinks:
- Downtown, price column:
- Downtown, cost column:
- Campus, price column:
- Campus, cost column:
Answer: The rows of are the locations and the columns are revenue and cost. Downtown brought in $410 in revenue and spent $110 making the drinks. Campus brought in $537.50 and spent $148.75.
(b) Profit is revenue minus cost. Downtown: . Campus: .
Answer: Campus made more profit, $388.75 compared with $300, which is $88.75 more.
(c) is and is , so is a matrix. But its entries are nonsense. The first one is : a latte's price times Downtown's lattes plus a latte's cost times Campus's lattes.
Answer: No. The sizes line up, but the meanings don't. In , the columns of (drinks) line up with the rows of (drinks). In a context problem, check that the labels match, not just the numbers.
Common mistakes
- Columns by rows. An matrix has rows and columns. Rows come first.
- Multiplying entry by entry. The entry of isn't . It's row 1 of dotted with column 1 of .
- Assuming . Matrix multiplication isn't commutative, and one order might not even be defined.
- Checking the wrong dimensions. Only the inside numbers have to match: works, but doesn't.
- Getting the size of the product wrong. The product takes the outside numbers, so is .