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.
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
Give the dimensions of \(A\) and the entry \(a_{23}\).
- 12 rows and 3 columns: \(A\) is a \(2 \times 3\) matrix (rows first, then columns).
- 2\(a_{23}\) is in row 2, column 3: 5.
Find \(P + Q\) and \(3P\) for the matrices in Worked Example 4.
- 1Matrices of the same size add entry by entry: \(\begin{bmatrix} 6 & 8 \\ 10 & 12 \end{bmatrix}\).
- 2A scalar multiplies every entry: \(3P = \begin{bmatrix} 3 & 6 \\ 9 & 12 \end{bmatrix}\).
2When a product exists
\(A\) is \(2 \times 3\) and \(B\) is \(3 \times 2\). Which of \(AB\), \(BA\) and \(AA\) are defined, and what size are they?
- 1A product needs the columns of the first to equal the rows of the second.
- 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\(AA\): \((2 \times 3)(2 \times 3)\), inner numbers 3 and 2 differ, not defined.
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
Find \(PQ\) and \(QP\).
- 1Row 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\).
- 2For \(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\).
Find \(A\vec x\).
- 1\((2 \times 3)(3 \times 1)\) gives a \(2 \times 1\) result.
- 2Row 1: \(2(1) + (-1)(2) + 0(-1) = 0\). Row 2: \(3(1) + 4(2) + 5(-1) = 6\).
“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\).”
\(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
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.
- 1Each row (a shopper’s quantities) times the price column gives that shopper’s total.
- 2First: \(4(0.50) + 1(2.50) + 2(1.20) = 6.90\). Second: \(6(0.50) + 2(2.50) + 1(1.20) = 9.20\).
Quick reference
| Idea | Rule |
|---|---|
| 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 multiple | Entry by entry (same sizes for a sum) |