Unit 6, lesson 80

Introduction to Matrices and Matrix Addition

What a matrix is, how to read its dimensions and entries, when two matrices are equal, and how to add, subtract and scale matrices one entry at a time.

  • Theory part 159
  • Practice part 160
  • Matrices

Two bike rental stations count how many city bikes, mountain bikes and electric bikes they rent out each week. That is six numbers, and they fall naturally into a grid with one row per station and one column per bike type. Such a grid is a matrix. Adding two weeks of counts, or scaling them for a forecast, is done spot by spot, and the same grids later hold the coefficients of whole linear systems.

Key terms

Matrix

Definition Let mm and nn be positive integers. An m×nm \times n matrix is a rectangular array of mnmn numbers, called its entries, arranged in mm horizontal rows and nn vertical columns. The entry in row ii and column jj is written aija_{ij}, and the whole matrix is written

A=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn]=[aij].\begin{aligned} A &= \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix} \\[0.8em] &= [a_{ij}]. \end{aligned}

In this course the entries are real numbers and the array is written in square brackets. Some books use large parentheses instead.

In plain words A matrix is a table of numbers without labels. Where a number sits tells you what it means, and its address gives the row first and the column second.

Example One week of rentals fits in a matrix whose rows are the two stations and whose columns are city, mountain and electric bikes,

A=[401525302010].A = \begin{bmatrix} 40 & 15 & 25 \\ 30 & 20 & 10 \end{bmatrix}.

The entry a23=10a_{23} = 10 sits in row 2 and column 3, so station 2 rented out 1010 electric bikes. The entry a12=15a_{12} = 15 counts mountain bikes at station 1.

Dimensions

Definition A matrix with mm rows and nn columns has dimensions m×nm \times n, read ”mm by nn”, with the number of rows always first. It has mnmn entries. A matrix with m=nm = n is square. A 1×n1 \times n matrix is a row matrix, or row vector, and an m×1m \times 1 matrix is a column matrix, or column vector. The size of a matrix means the same thing, and some books say order.

In plain words Count the rows down the side, then the columns across the top, and say them in that order.

Example The linear system below has two equations in the three variables xx, yy and zz.

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

Its coefficient matrix has one row per equation and one column per variable,

[2−13105],\begin{bmatrix} 2 & -1 & 3 \\ 1 & 0 & 5 \end{bmatrix},

so it is 2×32 \times 3. The second equation has no yy, which shows up as the entry 00. In this matrix a12=−1a_{12} = -1 and a23=5a_{23} = 5.

Equal matrices

Definition Two matrices A=[aij]A = [a_{ij}] and B=[bij]B = [b_{ij}] are equal, written A=BA = B, when they have the same dimensions and aij=bija_{ij} = b_{ij} for every row ii and every column jj.

In plain words Equal matrices have the same shape and the same number in every spot. So one equation between m×nm \times n matrices is really mnmn ordinary equations.

Example The matrix equation

[x+1432y]=[543−6]\begin{bmatrix} x + 1 & 4 \\ 3 & 2y \end{bmatrix} = \begin{bmatrix} 5 & 4 \\ 3 & -6 \end{bmatrix}

holds exactly when x+1=5x + 1 = 5 and 2y=−62y = -6, so x=4x = 4 and y=−3y = -3. The other two spots already agree. On the other hand, the row [12]\begin{bmatrix} 1 & 2 \end{bmatrix} and the column with entries 11 and 22 are not equal, because one is 1×21 \times 2 and the other is 2×12 \times 1.

Matrix addition

Definition If A=[aij]A = [a_{ij}] and B=[bij]B = [b_{ij}] are both m×nm \times n matrices, their sum is the m×nm \times n matrix

A+B=[aij+bij].A + B = [a_{ij} + b_{ij}].

The sum of two matrices with different dimensions is not defined.

In plain words Add the numbers that sit in the same spot. If the shapes do not match, some spots have no partner and there is no sum.

Example The second week of rentals is the matrix BB below, so the two weeks together are

A+B=[401525302010]+[382035252416]=[783560554426].\begin{aligned} A + B &= \begin{bmatrix} 40 & 15 & 25 \\ 30 & 20 & 10 \end{bmatrix} \\[0.8em] &\quad + \begin{bmatrix} 38 & 20 & 35 \\ 25 & 24 & 16 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} 78 & 35 & 60 \\ 55 & 44 & 26 \end{bmatrix}. \end{aligned}

Station 1 rented out 7878 city bikes over the two weeks. A 2×32 \times 3 matrix and a 3×23 \times 2 matrix cannot be added, even though both have six entries.

Scalar multiplication

Definition For a real number cc, called a scalar, and an m×nm \times n matrix A=[aij]A = [a_{ij}], the scalar multiple cAcA is the m×nm \times n matrix

cA=[c aij].cA = [c\,a_{ij}].

In plain words Multiply every entry by the same number. The shape stays the same.

Example Suppose a forecast expects 2020 percent more rentals in the same week next year. Every count in the first week’s matrix AA gets multiplied by 1.21.2,

1.2A=[1.2⋅401.2⋅151.2⋅251.2⋅301.2⋅201.2⋅10]=[481830362412].\begin{aligned} &1.2A \\[0.4em] &= \begin{bmatrix} 1.2 \cdot 40 & 1.2 \cdot 15 & 1.2 \cdot 25 \\ 1.2 \cdot 30 & 1.2 \cdot 20 & 1.2 \cdot 10 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} 48 & 18 & 30 \\ 36 & 24 & 12 \end{bmatrix}. \end{aligned}

Zero matrix and subtraction

Definition The m×nm \times n zero matrix OO has every entry equal to 00, and there is one for each choice of dimensions. The negative of A=[aij]A = [a_{ij}] is −A=(−1)A=[−aij]-A = (-1)A = [-a_{ij}]. For two m×nm \times n matrices the difference is

A−B=A+(−B)=[aij−bij].A - B = A + (-B) = [a_{ij} - b_{ij}].

In plain words Subtract spot by spot. Adding the zero matrix changes nothing, and any matrix minus itself is the zero matrix of the same shape.

Example The change from the first week to the second is

B−A=[38−4020−1535−2525−3024−2016−10]=[−2510−546].\begin{aligned} &B - A \\[0.4em] &= \begin{bmatrix} 38 - 40 & 20 - 15 & 35 - 25 \\ 25 - 30 & 24 - 20 & 16 - 10 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} -2 & 5 & 10 \\ -5 & 4 & 6 \end{bmatrix}. \end{aligned}

A negative entry marks a drop. Station 2 rented out 55 fewer city bikes in the second week, while electric bikes went up at both stations.

Rules of matrix arithmetic

Definition Let AA, BB and CC be m×nm \times n matrices, let OO be the m×nm \times n zero matrix, and let cc and dd be scalars. Then

A+B=B+A,(A+B)+C=A+(B+C),A+O=A,A+(−A)=O,c(A+B)=cA+cB,(c+d)A=cA+dA,c(dA)=(cd)A,1A=A.\begin{aligned} A + B &= B + A, \\[0.4em] (A + B) + C &= A + (B + C), \\[0.4em] A + O &= A, \\[0.4em] A + (-A) &= O, \\[0.4em] c(A + B) &= cA + cB, \\[0.4em] (c + d)A &= cA + dA, \\[0.4em] c(dA) &= (cd)A, \\[0.4em] 1A &= A. \end{aligned}

Each rule holds because the same rule holds for real numbers, applied in every spot.

In plain words Adding matrices and multiplying them by numbers follow the familiar rules of arithmetic. So a simple matrix equation can be solved the way you would solve one with numbers.

Example Find the matrix XX with 3X−A=B3X - A = B, where

A=[20−14],B=[46−2−1].\begin{aligned} A &= \begin{bmatrix} 2 & 0 \\ -1 & 4 \end{bmatrix}, \\[0.8em] B &= \begin{bmatrix} 4 & 6 \\ -2 & -1 \end{bmatrix}. \end{aligned}

Add AA to both sides and multiply by 13\tfrac{1}{3},

X=13(A+B)=13[66−33]=[22−11].\begin{aligned} X &= \frac{1}{3}(A + B) \\[0.8em] &= \frac{1}{3} \begin{bmatrix} 6 & 6 \\ -3 & 3 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} 2 & 2 \\ -1 & 1 \end{bmatrix}. \end{aligned}

As a check, 3X−A3X - A has top row 6−2=46 - 2 = 4 and 6−0=66 - 0 = 6 and bottom row −3+1=−2-3 + 1 = -2 and 3−4=−13 - 4 = -1, which is BB.

Check yourself

  1. Give the dimensions of the matrix below and the entries a23a_{23} and a14a_{14}.
[30−125471]\begin{bmatrix} 3 & 0 & -1 & 2 \\ 5 & 4 & 7 & 1 \end{bmatrix}
Show the answer

It has 22 rows and 44 columns, so it is 2×42 \times 4. The entry in row 2 and column 3 is a23=7a_{23} = 7, and the entry in row 1 and column 4 is a14=2a_{14} = 2.

  1. Compute 3A−2B3A - 2B for the matrices below.
A=[1−2043−1],B=[21−3052]\begin{aligned} A &= \begin{bmatrix} 1 & -2 & 0 \\ 4 & 3 & -1 \end{bmatrix}, \\[0.8em] B &= \begin{bmatrix} 2 & 1 & -3 \\ 0 & 5 & 2 \end{bmatrix} \end{aligned}
Show the answer

Scale each matrix and then subtract spot by spot,

3A−2B=[3−60129−3]−[42−60104]=[−1−8612−1−7].\begin{aligned} 3A - 2B &= \begin{bmatrix} 3 & -6 & 0 \\ 12 & 9 & -3 \end{bmatrix} \\[0.8em] &\quad - \begin{bmatrix} 4 & 2 & -6 \\ 0 & 10 & 4 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} -1 & -8 & 6 \\ 12 & -1 & -7 \end{bmatrix}. \end{aligned}
  1. Find the matrix XX with 2X+A=B2X + A = B for the matrices below.
A=[13−20],B=[5−146]A = \begin{bmatrix} 1 & 3 \\ -2 & 0 \end{bmatrix}, \qquad B = \begin{bmatrix} 5 & -1 \\ 4 & 6 \end{bmatrix}
Show the answer

Subtract AA and multiply by 12\tfrac{1}{2},

X=12(B−A)=12[4−466]=[2−233].\begin{aligned} X &= \frac{1}{2}(B - A) \\[0.8em] &= \frac{1}{2} \begin{bmatrix} 4 & -4 \\ 6 & 6 \end{bmatrix} \\[0.8em] &= \begin{bmatrix} 2 & -2 \\ 3 & 3 \end{bmatrix}. \end{aligned}

How this lesson connects