AP Precalculus · Study guide

Matrices

AP® Precalculus · Unit 4 · Functions Involving Parameters, Vectors, and Matrices

Matrices and Matrix Multiplication

A matrix is a rectangular array of numbers. Multiplying matrices combines rows of one with columns of the other. This guide covers dimensions, when a product exists, how to compute it, and why the order matters.

The idea in one paragraph

An \(n \times m\) matrix has \(n\) rows and \(m\) columns; \(a_{ij}\) is the entry in row \(i\), column \(j\). Two matrices can be multiplied when the number of columns of the first equals the number of rows of the second; an \((n \times m)(m \times p)\) product is \(n \times p\). The entry in row \(i\), column \(j\) of the product is the dot product of row \(i\) of the first matrix with column \(j\) of the second. Matrix multiplication is usually not commutative: \(AB\) and \(BA\) can differ, or one may not exist.

1Rows, columns and entries

Worked Example 1 Size and entries

Give the dimensions of \(A\) and the entry \(a_{23}\).

\[A = \begin{bmatrix} 2 & -1 & 0 \\ 3 & 4 & 5 \end{bmatrix}\]
  1. 1
    2 rows and 3 columns: \(A\) is a \(2 \times 3\) matrix (rows first, then columns).
  2. 2
    \(a_{23}\) is in row 2, column 3: 5.
Answer: \(2 \times 3\); \(a_{23} = 5\).
Worked Example 2 Adding and scaling

Find \(P + Q\) and \(3P\) for the matrices in Worked Example 4.

  1. 1
    Matrices of the same size add entry by entry: \(\begin{bmatrix} 6 & 8 \\ 10 & 12 \end{bmatrix}\).
  2. 2
    A scalar multiplies every entry: \(3P = \begin{bmatrix} 3 & 6 \\ 9 & 12 \end{bmatrix}\).
Answer: Entry-by-entry for sums; every entry for scalar multiples.

2When a product exists

Worked Example 3 Which products exist?

\(A\) is \(2 \times 3\) and \(B\) is \(3 \times 2\). Which of \(AB\), \(BA\) and \(AA\) are defined, and what size are they?

  1. 1
    A product needs the columns of the first to equal the rows of the second.
  2. 2
    \(AB\): \((2 \times 3)(3 \times 2)\), inner numbers match, result \(2 \times 2\). \(BA\): \((3 \times 2)(2 \times 3)\), result \(3 \times 3\).
  3. 3
    \(AA\): \((2 \times 3)(2 \times 3)\), inner numbers 3 and 2 differ, not defined.
Answer: \(AB\) is \(2 \times 2\), \(BA\) is \(3 \times 3\), \(AA\) is not defined.
Common Mistake 1 · Checking the outer numbers

For \((2 \times 3)(3 \times 2)\), the inner numbers (3 and 3) must match; the outer numbers (2 and 2) give the size of the answer. Matching the outer numbers proves nothing.

3Computing a product

Figure 1. To get the entry in row i, column j of a product, pair up row i of the first matrix with column j of the second, multiply matching entries, and add.
Worked Example 4 Multiplying 2 × 2 matrices, both orders

Find \(PQ\) and \(QP\).

\[P = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \qquad Q = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}\]
  1. 1
    Row 1 of \(P\) with each column of \(Q\): \(1(5) + 2(7) = 19\), \(1(6) + 2(8) = 22\). Row 2: \(3(5) + 4(7) = 43\), \(3(6) + 4(8) = 50\).
  2. 2
    For \(QP\): row 1 of \(Q\): \(5(1) + 6(3) = 23\), \(5(2) + 6(4) = 34\). Row 2: \(7(1) + 8(3) = 31\), \(7(2) + 8(4) = 46\).
Answer: \(PQ = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix}\), \(QP = \begin{bmatrix} 23 & 34 \\ 31 & 46 \end{bmatrix}\): not equal (Figure 1).
Worked Example 5 A matrix times a column

Find \(A\vec x\).

\[A = \begin{bmatrix} 2 & -1 & 0 \\ 3 & 4 & 5 \end{bmatrix}, \qquad \vec x = \begin{bmatrix} 1 \\ 2 \\ -1 \end{bmatrix}\]
  1. 1
    \((2 \times 3)(3 \times 1)\) gives a \(2 \times 1\) result.
  2. 2
    Row 1: \(2(1) + (-1)(2) + 0(-1) = 0\). Row 2: \(3(1) + 4(2) + 5(-1) = 6\).
Answer: \(A\vec x = \begin{bmatrix} 0 \\ 6 \end{bmatrix}\)
Write it like this

“The entry in row 2, column 1 of \(PQ\) is row 2 of \(P\) dotted with column 1 of \(Q\): \(3(5) + 4(7) = 43\).”

Common Mistake 2 · Multiplying entry by entry

\(PQ\) is not \(\begin{bmatrix} 5 & 12 \\ 21 & 32 \end{bmatrix}\). That entry-by-entry product is not how matrices multiply; each entry comes from a whole row and a whole column.

4Order matters

In Worked Example 4, \(PQ\) and \(QP\) have different entries. With non-square matrices one order can even be undefined. Always multiply in the order written.

5Matrices in context

Worked Example 6 Totals from a product

Two shoppers buy apples, bread and milk. The first buys 4, 1, 2; the second 6, 2, 1. Prices are 0.50, 2.50 and 1.20 dollars. Find each total with one matrix product.

\[\begin{bmatrix} 4 & 1 & 2 \\ 6 & 2 & 1 \end{bmatrix}\begin{bmatrix} 0.50 \\ 2.50 \\ 1.20 \end{bmatrix}\]
  1. 1
    Each row (a shopper’s quantities) times the price column gives that shopper’s total.
  2. 2
    First: \(4(0.50) + 1(2.50) + 2(1.20) = 6.90\). Second: \(6(0.50) + 2(2.50) + 1(1.20) = 9.20\).
Answer: 6.90 dollars and 9.20 dollars.

Quick reference

IdeaRule
Size\(n \times m\): \(n\) rows, \(m\) columns
Product exists\((n \times m)(m \times p)\): inner numbers match
Product size\(n \times p\)
Entry \(c_{ij}\)Row \(i\) of the first · column \(j\) of the second
Order\(AB \ne BA\) in general
Sum, scalar multipleEntry by entry (same sizes for a sum)