Skip to content
Family Table Math
Auto

Introduction to Matrices

A matrix is a rectangular table of numbers. Matrices are a compact way to store data, like the sales of several products in several shops, and they come with their own arithmetic. Matrix multiplication in particular turns out to be exactly what you need to combine tables of data, solve systems of equations, transform shapes, and model how populations move over time.

A matrix with mm rows and nn columns has order m×nm \times n (say ”mm by nn”). Rows go across, columns go down.

A=(3−14025)A = \begin{pmatrix} 3 & -1 & 4 \\ 0 & 2 & 5 \end{pmatrix}

AA has 22 rows and 33 columns, so its order is 2×32 \times 3. Each number is an element (or entry). The element in row ii, column jj is written aija_{ij}: here a13=4a_{13} = 4 and a21=0a_{21} = 0. Always give the row first, then the column.

Matrices are usually named with capital letters. A matrix with one column, like (27)\begin{pmatrix} 2 \\ 7 \end{pmatrix}, is a column matrix; a matrix with the same number of rows and columns is a square matrix.

Two matrices are equal if they have the same order and every pair of corresponding elements is equal. So a matrix equation gives one ordinary equation for each position.

Addition, subtraction and scalar multiplication

Section titled “Addition, subtraction and scalar multiplication”
  • Add or subtract matrices of the same order by adding or subtracting corresponding elements. Matrices of different orders can’t be added.
  • Multiply by a scalar (a number) kk by multiplying every element by kk.
(14−20)+(3−152)=(4332),3(14−20)=(312−60)\begin{pmatrix} 1 & 4 \\ -2 & 0 \end{pmatrix} + \begin{pmatrix} 3 & -1 \\ 5 & 2 \end{pmatrix} = \begin{pmatrix} 4 & 3 \\ 3 & 2 \end{pmatrix}, \qquad 3\begin{pmatrix} 1 & 4 \\ -2 & 0 \end{pmatrix} = \begin{pmatrix} 3 & 12 \\ -6 & 0 \end{pmatrix}

To find the element in row ii, column jj of ABAB, take row ii of AA and column jj of BB, multiply corresponding entries, and add:

(1234)(5678)=(1(5)+2(7)1(6)+2(8)3(5)+4(7)3(6)+4(8))=(19224350)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix} = \begin{pmatrix} 1(5) + 2(7) & 1(6) + 2(8) \\ 3(5) + 4(7) & 3(6) + 4(8) \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}

For this to work, each row of AA must be as long as each column of BB. The product ABAB exists only when

(m×n‾)×(n‾×p)  →  m×p(m \times \underline{n}) \times (\underline{n} \times p) \;\to\; m \times p

The inner numbers must match (the matrices are conformable); the outer numbers give the order of the answer. A 2×32 \times 3 matrix times a 3×43 \times 4 matrix gives a 2×42 \times 4 matrix, but a 2×32 \times 3 times a 2×32 \times 3 isn’t defined.

Your GDC’s matrix editor does all of this: enter the matrices (with their orders), then calculate with them on the home screen. You should still be able to multiply small matrices by hand.

For matrices of suitable orders:

PropertyStatement
Associative(AB)C=A(BC)(AB)C = A(BC)
DistributiveA(B+C)=AB+ACA(B + C) = AB + AC and (A+B)C=AC+BC(A + B)C = AC + BC
Not commutativein general, AB≠BAAB \ne BA

Because order matters, “multiply AA by BB on the left” (BABA) and “on the right” (ABAB) are different. ABAB might even exist when BABA doesn’t. Write A2A^2 for AAAA; it only makes sense for square matrices.

  • The identity matrix II is square, with 11s on the leading diagonal (top left to bottom right) and 00s elsewhere. It acts like the number 11: AI=IA=AAI = IA = A.
  • The zero matrix 00 has every element 00. It acts like the number 00: A+0=AA + 0 = A and A0=0A0 = 0.
I=(1001),I=(100010001),0=(0000)I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, \qquad I = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}, \qquad 0 = \begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix}
  • (a) For A=(3−14025)A = \begin{pmatrix} 3 & -1 & 4 \\ 0 & 2 & 5 \end{pmatrix}, write down the order of AA, and the values of a12a_{12} and a23a_{23}.
  • (b) Find xx and yy if (x+1432y)=(543−6)\begin{pmatrix} x + 1 & 4 \\ 3 & 2y \end{pmatrix} = \begin{pmatrix} 5 & 4 \\ 3 & -6 \end{pmatrix}.

Solution.

(a) 22 rows and 33 columns: order 2×32 \times 3. Row 11, column 22: a12=−1a_{12} = -1. Row 22, column 33: a23=5a_{23} = 5.

(b) Corresponding elements are equal: x+1=5x + 1 = 5, so x=4x = 4; and 2y=−62y = -6, so y=−3y = -3.

Let A=(2−143)A = \begin{pmatrix} 2 & -1 \\ 4 & 3 \end{pmatrix} and B=(15−20)B = \begin{pmatrix} 1 & 5 \\ -2 & 0 \end{pmatrix}. Find 2A−3B2A - 3B.

Solution. Multiply first, then subtract element by element:

2A−3B=(4−286)−(315−60)=(1−17146)2A - 3B = \begin{pmatrix} 4 & -2 \\ 8 & 6 \end{pmatrix} - \begin{pmatrix} 3 & 15 \\ -6 & 0 \end{pmatrix} = \begin{pmatrix} 1 & -17 \\ 14 & 6 \end{pmatrix}

Watch the signs: 8−(−6)=148 - (-6) = 14.

Let C=(120−134)C = \begin{pmatrix} 1 & 2 & 0 \\ -1 & 3 & 4 \end{pmatrix} and D=(210−352)D = \begin{pmatrix} 2 & 1 \\ 0 & -3 \\ 5 & 2 \end{pmatrix}. Find CDCD and DCDC, if they exist.

Solution. CC is 2×32 \times 3 and DD is 3×23 \times 2.

CDCD: (2×3)(3×2)(2 \times 3)(3 \times 2), inner numbers match, so CDCD is 2×22 \times 2.

CD=(1(2)+2(0)+0(5)1(1)+2(−3)+0(2)−1(2)+3(0)+4(5)−1(1)+3(−3)+4(2))=(2−518−2)CD = \begin{pmatrix} 1(2) + 2(0) + 0(5) & 1(1) + 2(-3) + 0(2) \\ -1(2) + 3(0) + 4(5) & -1(1) + 3(-3) + 4(2) \end{pmatrix} = \begin{pmatrix} 2 & -5 \\ 18 & -2 \end{pmatrix}

DCDC: (3×2)(2×3)(3 \times 2)(2 \times 3), inner numbers match, so DCDC is 3×33 \times 3. Using a GDC (or nine row-times-column sums):

DC=(1743−9−123168)DC = \begin{pmatrix} 1 & 7 & 4 \\ 3 & -9 & -12 \\ 3 & 16 & 8 \end{pmatrix}

CDCD and DCDC don’t even have the same order, a clear example of CD≠DCCD \ne DC.

A bakery has two shops. One Saturday they sold:

SandwichesSaladsDrinks
Shop A303012122020
Shop B252518181010

A sandwich costs $4.50, a salad $6.00 and a drink $3.25. Use matrix multiplication to find each shop’s revenue and the total.

Solution. Put the sales in a 2×32 \times 3 matrix SS and the prices in a 3×13 \times 1 column PP, in the same item order:

SP=(301220251810)(4.506.003.25)=(30(4.50)+12(6.00)+20(3.25)25(4.50)+18(6.00)+10(3.25))=(272253)SP = \begin{pmatrix} 30 & 12 & 20 \\ 25 & 18 & 10 \end{pmatrix}\begin{pmatrix} 4.50 \\ 6.00 \\ 3.25 \end{pmatrix} = \begin{pmatrix} 30(4.50) + 12(6.00) + 20(3.25) \\ 25(4.50) + 18(6.00) + 10(3.25) \end{pmatrix} = \begin{pmatrix} 272 \\ 253 \end{pmatrix}

Shop A took in $272 and Shop B $253. To total them, multiply on the left by a row of 11s:

(11)(272253)=(525)\begin{pmatrix} 1 & 1 \end{pmatrix}\begin{pmatrix} 272 \\ 253 \end{pmatrix} = (525)

The total revenue was $525. The columns of SS (items) matched the rows of PP (items), which is why the product makes sense.

Giving the order as columns by rows. Order is always rows ×\times columns. A matrix with 22 rows and 33 columns is 2×32 \times 3, and a23a_{23} is in row 22, column 33.

Multiplying element by element. ABAB is not found by multiplying matching positions. Each entry is a row of AA times a column of BB, added up.

Assuming AB = BA. Matrix multiplication isn’t commutative. Keep the order exactly as written, and in expansions write (A+B)2=A2+AB+BA+B2(A + B)^2 = A^2 + AB + BA + B^2, not A2+2AB+B2A^2 + 2AB + B^2.

Trying to multiply matrices that aren’t conformable. Check the orders first: the number of columns of the first must equal the number of rows of the second.

Adding matrices of different orders. A 2×22 \times 2 and a 2×32 \times 3 matrix can’t be added. Your GDC will give a dimension error, and so should you.

Lining up a data product the wrong way. In Example 4, PSPS isn’t defined (3×13 \times 1 times 2×32 \times 3). The items must be the columns of the first matrix and the rows of the second.

1. (Warm-up) For M=(70−3219)M = \begin{pmatrix} 7 & 0 \\ -3 & 2 \\ 1 & 9 \end{pmatrix}, write down the order of MM and the values of m21m_{21} and m32m_{32}.

Solution

33 rows and 22 columns: order 3×23 \times 2. Row 22, column 11: m21=−3m_{21} = -3. Row 33, column 22: m32=9m_{32} = 9.

2. (Warm-up) Find aa, bb and cc if (2ab−34c2)=(10−1416)\begin{pmatrix} 2a & b - 3 \\ 4 & c^2 \end{pmatrix} = \begin{pmatrix} 10 & -1 \\ 4 & 16 \end{pmatrix} and c>0c \gt 0.

Solution

2a=102a = 10, so a=5a = 5. b−3=−1b - 3 = -1, so b=2b = 2. c2=16c^2 = 16 with c>0c \gt 0, so c=4c = 4.

3. (Warm-up) Let P=(30−25)P = \begin{pmatrix} 3 & 0 \\ -2 & 5 \end{pmatrix} and Q=(−1462)Q = \begin{pmatrix} -1 & 4 \\ 6 & 2 \end{pmatrix}. Find:

  • (a) P+QP + Q
  • (b) 3P−2Q3P - 2Q
Solution

(a)

P+Q=(3+(−1)0+4−2+65+2)=(2447)P + Q = \begin{pmatrix} 3 + (-1) & 0 + 4 \\ -2 + 6 & 5 + 2 \end{pmatrix} = \begin{pmatrix} 2 & 4 \\ 4 & 7 \end{pmatrix}

(b)

3P−2Q=(90−615)−(−28124)=(11−8−1811)3P - 2Q = \begin{pmatrix} 9 & 0 \\ -6 & 15 \end{pmatrix} - \begin{pmatrix} -2 & 8 \\ 12 & 4 \end{pmatrix} = \begin{pmatrix} 11 & -8 \\ -18 & 11 \end{pmatrix}

4. (Core) Let P=(3−214)P = \begin{pmatrix} 3 & -2 \\ 1 & 4 \end{pmatrix} and Q=(05−12)Q = \begin{pmatrix} 0 & 5 \\ -1 & 2 \end{pmatrix}. Find PQPQ and QPQP by hand.

SolutionPQ=(3(0)+(−2)(−1)3(5)+(−2)(2)1(0)+4(−1)1(5)+4(2))=(211−413)PQ = \begin{pmatrix} 3(0) + (-2)(-1) & 3(5) + (-2)(2) \\ 1(0) + 4(-1) & 1(5) + 4(2) \end{pmatrix} = \begin{pmatrix} 2 & 11 \\ -4 & 13 \end{pmatrix}QP=(0(3)+5(1)0(−2)+5(4)−1(3)+2(1)−1(−2)+2(4))=(520−110)QP = \begin{pmatrix} 0(3) + 5(1) & 0(-2) + 5(4) \\ -1(3) + 2(1) & -1(-2) + 2(4) \end{pmatrix} = \begin{pmatrix} 5 & 20 \\ -1 & 10 \end{pmatrix}

PQ≠QPPQ \ne QP.

5. (Core) AA is 2×32 \times 3, BB is 3×33 \times 3 and CC is 3×13 \times 1. For each product, say whether it exists, and if it does, give its order.

  • (a) ABAB
  • (b) BABA
  • (c) BCBC
  • (d) ABCABC
  • (e) CACA
Solution

(a) (2×3)(3×3)(2 \times 3)(3 \times 3): exists, order 2×32 \times 3.

(b) (3×3)(2×3)(3 \times 3)(2 \times 3): 3≠23 \ne 2, so it doesn’t exist.

(c) (3×3)(3×1)(3 \times 3)(3 \times 1): exists, order 3×13 \times 1.

(d) ABAB is 2×32 \times 3, then (2×3)(3×1)(2 \times 3)(3 \times 1): exists, order 2×12 \times 1.

(e) (3×1)(2×3)(3 \times 1)(2 \times 3): 1≠21 \ne 2, so it doesn’t exist.

6. (Core) Let A=(120−1)A = \begin{pmatrix} 1 & 2 \\ 0 & -1 \end{pmatrix} and B=(3110)B = \begin{pmatrix} 3 & 1 \\ 1 & 0 \end{pmatrix}.

  • (a) Show that AB≠BAAB \ne BA.
  • (b) Find A2A^2. What do you notice?
Solution

(a)

AB=(3+21+00−10+0)=(51−10),BA=(3+06−11+02+0)=(3512)AB = \begin{pmatrix} 3 + 2 & 1 + 0 \\ 0 - 1 & 0 + 0 \end{pmatrix} = \begin{pmatrix} 5 & 1 \\ -1 & 0 \end{pmatrix}, \qquad BA = \begin{pmatrix} 3 + 0 & 6 - 1 \\ 1 + 0 & 2 + 0 \end{pmatrix} = \begin{pmatrix} 3 & 5 \\ 1 & 2 \end{pmatrix}

These are different, so AB≠BAAB \ne BA.

(b)

A2=(120−1)(120−1)=(1+02−20+00+1)=(1001)=IA^2 = \begin{pmatrix} 1 & 2 \\ 0 & -1 \end{pmatrix}\begin{pmatrix} 1 & 2 \\ 0 & -1 \end{pmatrix} = \begin{pmatrix} 1 + 0 & 2 - 2 \\ 0 + 0 & 0 + 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I

Multiplying by AA twice gets you back where you started.

7. (Core) A café makes pancake batter and cake batter. One batch of each needs:

Flour (kg)Milk (L)Butter (kg)
Pancake batter223311
Cake batter114422

Flour costs $2.40 per kg, milk $1.80 per litre and butter $6.50 per kg. Use matrix multiplication to find the cost of one batch of each.

Solution(231142)(2.401.806.50)=(4.80+5.40+6.502.40+7.20+13.00)=(16.7022.60)\begin{pmatrix} 2 & 3 & 1 \\ 1 & 4 & 2 \end{pmatrix}\begin{pmatrix} 2.40 \\ 1.80 \\ 6.50 \end{pmatrix} = \begin{pmatrix} 4.80 + 5.40 + 6.50 \\ 2.40 + 7.20 + 13.00 \end{pmatrix} = \begin{pmatrix} 16.70 \\ 22.60 \end{pmatrix}

A batch of pancake batter costs $16.70 and a batch of cake batter costs $22.60.

8. (Challenge) Let A=(2103)A = \begin{pmatrix} 2 & 1 \\ 0 & 3 \end{pmatrix} and B=(a10b)B = \begin{pmatrix} a & 1 \\ 0 & b \end{pmatrix}. Find the relationship between aa and bb for which AB=BAAB = BA.

SolutionAB=(2a+02(1)+1(b)0+00+3b)=(2a2+b03b)AB = \begin{pmatrix} 2a + 0 & 2(1) + 1(b) \\ 0 + 0 & 0 + 3b \end{pmatrix} = \begin{pmatrix} 2a & 2 + b \\ 0 & 3b \end{pmatrix}BA=(2a+0a(1)+1(3)0+00+3b)=(2aa+303b)BA = \begin{pmatrix} 2a + 0 & a(1) + 1(3) \\ 0 + 0 & 0 + 3b \end{pmatrix} = \begin{pmatrix} 2a & a + 3 \\ 0 & 3b \end{pmatrix}

The other entries already match, so AB=BAAB = BA exactly when 2+b=a+32 + b = a + 3, that is, a=b−1a = b - 1.

9. (Challenge) Let X=(1101)X = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} and Y=(0010)Y = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}.

  • (a) Find (X+Y)2(X + Y)^2 and X2+2XY+Y2X^2 + 2XY + Y^2.
  • (b) Explain why they are different.
Solution

(a) X+Y=(1111)X + Y = \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}, so

(X+Y)2=(1111)(1111)=(2222)(X + Y)^2 = \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}\begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix} = \begin{pmatrix} 2 & 2 \\ 2 & 2 \end{pmatrix}

X2=(1201)X^2 = \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix}, XY=(1010)XY = \begin{pmatrix} 1 & 0 \\ 1 & 0 \end{pmatrix} and Y2=(0000)Y^2 = \begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix}, so

X2+2XY+Y2=(1201)+(2020)+(0000)=(3221)X^2 + 2XY + Y^2 = \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix} + \begin{pmatrix} 2 & 0 \\ 2 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix} = \begin{pmatrix} 3 & 2 \\ 2 & 1 \end{pmatrix}

(b) Expanding with the distributive law gives (X+Y)2=X2+XY+YX+Y2(X + Y)^2 = X^2 + XY + YX + Y^2. Writing XY+YXXY + YX as 2XY2XY assumes XY=YXXY = YX, but here YX=(0011)≠XYYX = \begin{pmatrix} 0 & 0 \\ 1 & 1 \end{pmatrix} \ne XY. Check: X2+XY+YX+Y2=(2222)X^2 + XY + YX + Y^2 = \begin{pmatrix} 2 & 2 \\ 2 & 2 \end{pmatrix} ✓.