Dove's LibraryDove's Library

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 n×mn \times m matrix (read "n by m") is an array with nn rows and mm columns. Rows run across and columns run down. The number of rows always comes first.
A=[1203−14]is 2×3,B=[2105−23]is 3×2A = \begin{bmatrix} 1 & 2 & 0 \\ 3 & -1 & 4 \end{bmatrix} \quad \text{is } 2 \times 3, \qquad B = \begin{bmatrix} 2 & 1 \\ 0 & 5 \\ -2 & 3 \end{bmatrix} \quad \text{is } 3 \times 2
  • Entries: the number in row ii and column jj is called the (i,j)(i, j) entry, written aija_{ij}. In AA above, a23=4a_{23} = 4 (row 2, column 3).
  • Square matrix: a matrix with the same number of rows and columns, like a 2×22 \times 2 matrix.
  • Row and column vectors: a 1×m1 \times m matrix is a single row, and an n×1n \times 1 matrix is a single column. The vector ⟨a,b⟩\langle a, b \rangle is often written as the column [ab]\begin{bmatrix} a \\ b \end{bmatrix}, 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:
4.10 - Matrices
  • The inside numbers have to match.
  • The outside numbers give the size of the product.
So a 2×32 \times 3 matrix times a 3×23 \times 2 matrix is a 2×22 \times 2 matrix, but a 2×32 \times 3 matrix times another 2×32 \times 3 matrix isn't defined.

How to multiply

The product ABAB is a new matrix. The entry in row ii and column jj of ABAB is the dot product of row ii of AA and column jj of BB: multiply matching entries and add.
That's why the inside dimensions have to match. A row of AA has as many entries as AA has columns, a column of BB has as many entries as BB has rows, and a dot product needs the same number of entries on each side.
4.10 - Matrices

Example 1: Which products exist?

AA is 2×32 \times 3, BB is 3×23 \times 2, CC is 2×22 \times 2, and DD is 3×13 \times 1. Which of ABAB, BABA, ACAC, CACA, ADAD, and DADA are defined, and what size is each one?
Product
Dimensions
Inside numbers match?
Size of product
ABAB
(2×3)(3×2)(2 \times 3)(3 \times 2)
yes
2×22 \times 2
BABA
(3×2)(2×3)(3 \times 2)(2 \times 3)
yes
3×33 \times 3
ACAC
(2×3)(2×2)(2 \times 3)(2 \times 2)
no, 3≠23 \neq 2
not defined
CACA
(2×2)(2×3)(2 \times 2)(2 \times 3)
yes
2×32 \times 3
ADAD
(2×3)(3×1)(2 \times 3)(3 \times 1)
yes
2×12 \times 1
DADA
(3×1)(2×3)(3 \times 1)(2 \times 3)
no, 1≠21 \neq 2
not defined
Answer: ABAB (2×22 \times 2), BABA (3×33 \times 3), CACA (2×32 \times 3), and ADAD (2×12 \times 1) are defined, and ACAC and DADA aren't. Notice that ABAB and BABA are both defined but aren't even the same size.

Example 2: Multiplying 2×22 \times 2 matrices

Let P=[2−134]P = \begin{bmatrix} 2 & -1 \\ 3 & 4 \end{bmatrix} and Q=[15−20]Q = \begin{bmatrix} 1 & 5 \\ -2 & 0 \end{bmatrix}. Find PQPQ and QPQP.
Step 1: Find PQPQ. It's 2×22 \times 2, and each entry is a row of PP dotted with a column of QQ:
  • Row 1, column 1: (2)(1)+(−1)(−2)=2+2=4(2)(1) + (-1)(-2) = 2 + 2 = 4
  • Row 1, column 2: (2)(5)+(−1)(0)=10(2)(5) + (-1)(0) = 10
  • Row 2, column 1: (3)(1)+(4)(−2)=3−8=−5(3)(1) + (4)(-2) = 3 - 8 = -5
  • Row 2, column 2: (3)(5)+(4)(0)=15(3)(5) + (4)(0) = 15
PQ=[410−515]PQ = \begin{bmatrix} 4 & 10 \\ -5 & 15 \end{bmatrix}
Step 2: Find QPQP. Now use rows of QQ and columns of PP:
QP=[(1)(2)+(5)(3)(1)(−1)+(5)(4)(−2)(2)+(0)(3)(−2)(−1)+(0)(4)]=[1719−42]QP = \begin{bmatrix} (1)(2) + (5)(3) & (1)(-1) + (5)(4) \\ (-2)(2) + (0)(3) & (-2)(-1) + (0)(4) \end{bmatrix} = \begin{bmatrix} 17 & 19 \\ -4 & 2 \end{bmatrix}
Answer: PQ=[410−515]PQ = \begin{bmatrix} 4 & 10 \\ -5 & 15 \end{bmatrix} and QP=[1719−42]QP = \begin{bmatrix} 17 & 19 \\ -4 & 2 \end{bmatrix}. They're different. Order matters in matrix multiplication: in general, AB≠BAAB \neq BA.

Example 3: Matrices of different sizes

Find ABAB for A=[1203−14]A = \begin{bmatrix} 1 & 2 & 0 \\ 3 & -1 & 4 \end{bmatrix} and B=[2105−23]B = \begin{bmatrix} 2 & 1 \\ 0 & 5 \\ -2 & 3 \end{bmatrix}.
Step 1: Size. (2×3)(3×2)(2 \times 3)(3 \times 2) works, and ABAB is 2×22 \times 2.
Step 2: Entries. Each one is a row of AA (3 entries) dotted with a column of BB (3 entries):
  • Row 1, column 1: (1)(2)+(2)(0)+(0)(−2)=2(1)(2) + (2)(0) + (0)(-2) = 2
  • Row 1, column 2: (1)(1)+(2)(5)+(0)(3)=11(1)(1) + (2)(5) + (0)(3) = 11
  • Row 2, column 1: (3)(2)+(−1)(0)+(4)(−2)=6+0−8=−2(3)(2) + (-1)(0) + (4)(-2) = 6 + 0 - 8 = -2
  • Row 2, column 2: (3)(1)+(−1)(5)+(4)(3)=3−5+12=10(3)(1) + (-1)(5) + (4)(3) = 3 - 5 + 12 = 10
AB=[211−210]AB = \begin{bmatrix} 2 & 11 \\ -2 & 10 \end{bmatrix}
The row 2, column 1 entry is the one shown in the figure above. Multiplying in the other order gives a 3×33 \times 3 matrix:
BA=[53415−5207−712]BA = \begin{bmatrix} 5 & 3 & 4 \\ 15 & -5 & 20 \\ 7 & -7 & 12 \end{bmatrix}
Answer: AB=[211−210]AB = \begin{bmatrix} 2 & 11 \\ -2 & 10 \end{bmatrix}. Here ABAB and BABA can't be equal, since they aren't even the same size.

A matrix times a vector

A 2×22 \times 2 matrix times a column vector (2×12 \times 1) gives another column vector (2×12 \times 1). It's the same rule, row times column:
[2−134][52]=[(2)(5)+(−1)(2)(3)(5)+(4)(2)]=[823]\begin{bmatrix} 2 & -1 \\ 3 & 4 \end{bmatrix}\begin{bmatrix} 5 \\ 2 \end{bmatrix} = \begin{bmatrix} (2)(5) + (-1)(2) \\ (3)(5) + (4)(2) \end{bmatrix} = \begin{bmatrix} 8 \\ 23 \end{bmatrix}
The matrix turned the vector ⟨5,2⟩\langle 5, 2 \rangle into the vector ⟨8,23⟩\langle 8, 23 \rangle. 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 SS gives one day's sales, with rows for the Downtown and Campus locations and columns for lattes, teas, and cold brews. Matrix MM 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.)
S=[402530552045],M=[5.001.503.000.504.501.25]S = \begin{bmatrix} 40 & 25 & 30 \\ 55 & 20 & 45 \end{bmatrix}, \qquad M = \begin{bmatrix} 5.00 & 1.50 \\ 3.00 & 0.50 \\ 4.50 & 1.25 \end{bmatrix}
(a) Find SMSM and explain what each entry means. (b) Which location made more profit that day, and by how much? (c) MSMS is also defined. Does it mean anything?
(a) SS is 2×32 \times 3 and MM is 3×23 \times 2, so SMSM is 2×22 \times 2. The inside number, 3, counts the drinks, so each dot product adds up over the three drinks:
  • Downtown, price column: 40(5.00)+25(3.00)+30(4.50)=200+75+135=41040(5.00) + 25(3.00) + 30(4.50) = 200 + 75 + 135 = 410
  • Downtown, cost column: 40(1.50)+25(0.50)+30(1.25)=60+12.50+37.50=11040(1.50) + 25(0.50) + 30(1.25) = 60 + 12.50 + 37.50 = 110
  • Campus, price column: 55(5.00)+20(3.00)+45(4.50)=275+60+202.50=537.5055(5.00) + 20(3.00) + 45(4.50) = 275 + 60 + 202.50 = 537.50
  • Campus, cost column: 55(1.50)+20(0.50)+45(1.25)=82.50+10+56.25=148.7555(1.50) + 20(0.50) + 45(1.25) = 82.50 + 10 + 56.25 = 148.75
SM=[410110537.50148.75]SM = \begin{bmatrix} 410 & 110 \\ 537.50 & 148.75 \end{bmatrix}
Answer: The rows of SMSM 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: 410−110=300410 - 110 = 300. Campus: 537.50−148.75=388.75537.50 - 148.75 = 388.75.
Answer: Campus made more profit, $388.75 compared with $300, which is $88.75 more.
(c) MM is 3×23 \times 2 and SS is 2×32 \times 3, so MSMS is a 3×33 \times 3 matrix. But its entries are nonsense. The first one is 5.00(40)+1.50(55)5.00(40) + 1.50(55): 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 SMSM, the columns of SS (drinks) line up with the rows of MM (drinks). In a context problem, check that the labels match, not just the numbers.

Common mistakes

  • Columns by rows. An n×mn \times m matrix has nn rows and mm columns. Rows come first.
  • Multiplying entry by entry. The (1,1)(1, 1) entry of ABAB isn't a11b11a_{11}b_{11}. It's row 1 of AA dotted with column 1 of BB.
  • Assuming AB=BAAB = BA. Matrix multiplication isn't commutative, and one order might not even be defined.
  • Checking the wrong dimensions. Only the inside numbers have to match: (2×3)(3×4)(2 \times 3)(3 \times 4) works, but (2×3)(2×3)(2 \times 3)(2 \times 3) doesn't.
  • Getting the size of the product wrong. The product takes the outside numbers, so (2×3)(3×4)(2 \times 3)(3 \times 4) is 2×42 \times 4.

AP® is a registered trademark of the College Board, which is not affiliated with Dove's Library and was not involved in the production of, and does not endorse, this website.

Providing free, high-quality AP notes to help students succeed, earn college credit, and reach their educational goals, ensuring everyone has access to the resources they need.

© 2026 Standard Learning Group, Inc., which operates Dove's Library. All rights reserved.