Math Core

Lesson 9.2 · Systems and Matrices

Matrices and matrix operations

In the last lesson a matrix was just a tidy way to store a system. Matrices are much more useful than that: you can add them, scale them and multiply them, and those operations let you write an entire system of equations as one short equation. This lesson sets up the vocabulary and the arithmetic, with special attention to matrix multiplication, which works differently from anything you have multiplied before.

Matrix vocabulary

Definition

Matrix

A matrix is a rectangular array of numbers called entries. A matrix with mm rows and nn columns has dimensions m×nm \times n (read "mm by nn"). The entry in row ii and column jj of matrix AA is written aija_{ij}.

Rows always come first: both in the dimensions and in the subscripts. For example,

A=[4−1702−5]A = \begin{bmatrix} 4 & -1 & 7 \\ 0 & 2 & -5 \end{bmatrix}

is a 2×32 \times 3 matrix, and a23=−5a_{23} = -5 because −5-5 sits in row 2, column 3. A matrix with the same number of rows and columns is square. A matrix with a single column, such as [3−2]\begin{bmatrix} 3 \\ -2 \end{bmatrix}, is a column matrix (or column vector).

Two matrices are equal when they have the same dimensions and every pair of corresponding entries is equal. That gives you one ordinary equation for each entry.

Addition, subtraction and scalar multiplication

These operations work entry by entry, just as you would guess.

  • To add or subtract two matrices, they must have the same dimensions. Add or subtract corresponding entries.
  • To multiply a matrix by a number kk (a scalar), multiply every entry by kk.

Worked example: A linear combination of matrices

Let A=[2−103]A = \begin{bmatrix} 2 & -1 \\ 0 & 3 \end{bmatrix} and B=[45−21]B = \begin{bmatrix} 4 & 5 \\ -2 & 1 \end{bmatrix}. Find 3A−B3A - B.

First scale AA: 3A=[6−309]3A = \begin{bmatrix} 6 & -3 \\ 0 & 9 \end{bmatrix}. Then subtract entry by entry:

3A−B=[6−4−3−50−(−2)9−1]=[2−828].3A - B = \begin{bmatrix} 6 - 4 & -3 - 5 \\ 0 - (-2) & 9 - 1 \end{bmatrix} = \begin{bmatrix} 2 & -8 \\ 2 & 8 \end{bmatrix}.

Matrix addition behaves like ordinary addition: it is commutative (A+B=B+AA + B = B + A) and associative, and the zero matrix OO (all entries 00) plays the role of 00.

Matrix multiplication

Multiplying matrices is not entry by entry. The product is built from rows of the first matrix and columns of the second.

Row-times-column rule

If AA is m×nm \times n and BB is n×pn \times p, then ABAB is the m×pm \times p matrix whose entry in row ii, column jj is

(row i of A)⋅(column j of B),(\text{row } i \text{ of } A) \cdot (\text{column } j \text{ of } B),

found by multiplying matching entries and adding. The product is defined only when the number of columns of AA equals the number of rows of BB.

A quick way to check the dimensions: write them side by side. For (2×3)(3×4)(2 \times 3)(3 \times 4), the inner numbers match (3=33 = 3), so the product exists, and the outer numbers give its size, 2×42 \times 4. For (2×3)(2×3)(2 \times 3)(2 \times 3) the inner numbers are 33 and 22, so the product is undefined.

Worked example: Multiplying a 2 × 3 matrix by a 3 × 2 matrix

Find ABAB for

A=[120−132],B=[210−143].A = \begin{bmatrix} 1 & 2 & 0 \\ -1 & 3 & 2 \end{bmatrix}, \qquad B = \begin{bmatrix} 2 & 1 \\ 0 & -1 \\ 4 & 3 \end{bmatrix}.

The product is (2×3)(3×2)(2 \times 3)(3 \times 2), so ABAB is 2×22 \times 2. Compute each entry as a row times a column:

row 1, col 1:1(2)+2(0)+0(4)=2row 1, col 2:1(1)+2(−1)+0(3)=−1row 2, col 1:−1(2)+3(0)+2(4)=6row 2, col 2:−1(1)+3(−1)+2(3)=2\begin{aligned} \text{row 1, col 1:}&\quad 1(2) + 2(0) + 0(4) = 2 \\ \text{row 1, col 2:}&\quad 1(1) + 2(-1) + 0(3) = -1 \\ \text{row 2, col 1:}&\quad -1(2) + 3(0) + 2(4) = 6 \\ \text{row 2, col 2:}&\quad -1(1) + 3(-1) + 2(3) = 2 \end{aligned}

So AB=[2−162]AB = \begin{bmatrix} 2 & -1 \\ 6 & 2 \end{bmatrix}. Notice that BABA is also defined, but it is (3×2)(2×3)=3×3(3 \times 2)(2 \times 3) = 3 \times 3, a completely different matrix.

Common mistake

Matrix multiplication is not commutative: in general AB≠BAAB \ne BA. Sometimes one product exists and the other does not, and even for square matrices of the same size the two products usually differ. Always keep track of which matrix is on the left.

Worked example: Order matters

Let A=[1101]A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} and B=[1011]B = \begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}. Then

AB=[1+10+10+10+1]=[2111],BA=[1+01+01+01+1]=[1112].AB = \begin{bmatrix} 1 + 1 & 0 + 1 \\ 0 + 1 & 0 + 1 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}, \qquad BA = \begin{bmatrix} 1 + 0 & 1 + 0 \\ 1 + 0 & 1 + 1 \end{bmatrix} = \begin{bmatrix} 1 & 1 \\ 1 & 2 \end{bmatrix}.

Same two matrices, different products.

Multiplication does keep several familiar properties: it is associative, (AB)C=A(BC)(AB)C = A(BC), and it distributes over addition, A(B+C)=AB+ACA(B + C) = AB + AC. Powers of a square matrix mean repeated multiplication: A2=AAA^2 = AA.

The identity matrix

The identity matrix InI_n is the n×nn \times n matrix with 11s on the main diagonal (top left to bottom right) and 00s everywhere else:

I2=[1001],I3=[100010001].I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}, \qquad I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}.

For any square matrix AA of the same size, AI=IA=AAI = IA = A. The identity plays the role that the number 11 plays for ordinary multiplication, and it is the key to the next lesson on inverse matrices.

Systems as matrix equations

Here is the payoff. The system

2x+3y=5x−4y=−3\begin{aligned} 2x + 3y &= 5 \\ x - 4y &= -3 \end{aligned}

can be written as

[231−4][xy]=[5−3].\begin{bmatrix} 2 & 3 \\ 1 & -4 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 5 \\ -3 \end{bmatrix}.

Multiply out the left side with the row-times-column rule and you get the column [2x+3yx−4y]\begin{bmatrix} 2x + 3y \\ x - 4y \end{bmatrix}, so setting it equal to the right side reproduces both equations. In short form this is AX=BAX = B, where AA is the coefficient matrix, XX is the column of variables and BB is the column of constants. Any linear system, no matter how many variables, fits this pattern.

Tip

To double-check a product, look at the dimensions before computing. If AA is m×nm \times n, every row of AA has nn entries, and each column of BB must also have exactly nn entries for the dot products to line up.

Practice

Practice 1

What are the dimensions of [123456]\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}?

Practice 2

For A=[4−1702−5381]A = \begin{bmatrix} 4 & -1 & 7 \\ 0 & 2 & -5 \\ 3 & 8 & 1 \end{bmatrix}, what is a23a_{23}?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

Let A=[3−214]A = \begin{bmatrix} 3 & -2 \\ 1 & 4 \end{bmatrix} and B=[05−32]B = \begin{bmatrix} 0 & 5 \\ -3 & 2 \end{bmatrix}. What is the entry in row 2, column 1 of A+2BA + 2B?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

Let A=[2−134]A = \begin{bmatrix} 2 & -1 \\ 3 & 4 \end{bmatrix} and B=[501−2]B = \begin{bmatrix} 5 & 0 \\ 1 & -2 \end{bmatrix}. What is the entry in row 2, column 1 of ABAB?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

Matrix AA is 3×43 \times 4 and matrix BB is 4×24 \times 2. Which statement is true?

Practice 6

Compute [1234][0110]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.

Practice 7

Find (x,y)(x, y) if [x+y32x−y]=[7321]\begin{bmatrix} x + y & 3 \\ 2 & x - y \end{bmatrix} = \begin{bmatrix} 7 & 3 \\ 2 & 1 \end{bmatrix}.

Enter a point like (2, -3)

Practice 8

Let A=[12−10]A = \begin{bmatrix} 1 & 2 \\ -1 & 0 \end{bmatrix}. What is the entry in row 2, column 2 of A2A^2?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.