Skip to content

A matrix moves the plane

Watch a matrix move the whole grid, read where the two unit arrows land, and compute a matrix times a vector two ways.

Helps to know first
This topic

First, the picture

A matrix is a rule that moves every point of the plane at once. Watch the grid and its two arrows glide to their new place.

A matrix moves the plane

The columns of A are where the unit arrows e_1 and e_2 land.

Before the matrix acts: the square grid, and the unit arrows e_1 and e_2.

tip of e_1
(1, 0)
tip of e_2
(0, 1)
0.00 / 8.00 s
Describe this picture

One panel: a faint square grid with the origin at its centre, and two unit arrows from the origin, e1\mathbf{e}_1 pointing right and e2\mathbf{e}_2 pointing up, with the unit square between them shaded. After a second’s rest the grid glides, over 5 s, from its square starting place to the place the matrix sends it, turning a little and stretching at the same time, and holds there. The arrow e1\mathbf{e}_1 rides out to (2,1)(2,1) and e2\mathbf{e}_2 to (−1,1)(-1,1), and the shaded square becomes a parallelogram. The grid lines stay straight and evenly spaced the whole time, and the origin never moves. Readouts give the coordinates of the two arrow tips. When the clip has finished, a dashed ring marks each tip: either can be dragged, or moved with the arrow keys, in steps of half a unit, and the whole grid follows; the matrix is kept in the link.

Where the two arrows land

A point in the plane, say (3,2)(3,2), is a set of instructions: take 3 steps along the first unit arrow and 2 steps along the second. You met this reading in Vectors and Linear combinations and span. I’ll call the two unit arrows e1=(1,0)\mathbf{e}_1=(1,0) and e2=(0,1)\mathbf{e}_2=(0,1). A bold e\mathbf{e} with a number under it always means one of these arrows on this site, never the number ee.

So what happens if I move the two arrows? Every point is built from them, so every point has to move with them. The point (3,2)(3,2) is still “3 steps along the first arrow and 2 along the second”, only the arrows are different now.

That is the whole idea of a matrix. It is the table of where the two arrows go. In the picture at the top of the page, e1\mathbf{e}_1 lands on (2,1)(2,1) and e2\mathbf{e}_2 lands on (−1,1)(-1,1). I write those two landing places side by side, as columns:

A=[2−111].\mathbf{A}=\begin{bmatrix}2&-1\\1&1\end{bmatrix}.

The first column is where e1\mathbf{e}_1 goes. The second column is where e2\mathbf{e}_2 goes. I’ll call the columns a1=(2,1)\mathbf{a}_1=(2,1) and a2=(−1,1)\mathbf{a}_2=(-1,1). To save space I write a column of numbers on one line, as (2,1)(2,1); it still means a column.

A common slip is to read the rows as the landing places. The first row here is 2, −12,\,-1, but e1\mathbf{e}_1 lands on (2,1)(2,1), the first column. I chose a matrix whose rows and columns differ, so the slip cannot go unnoticed.

After the clip, drag the tip of either arrow. The whole grid follows it, because every point is built from the two arrows.

Same steps, new arrows

Now follow one point. The point (3,2)(3,2) starts as 3 steps of e1\mathbf{e}_1 followed by 2 steps of e2\mathbf{e}_2. Watch the same steps being taken with the new arrows.

The point rides along

x = (3, 2) as steps along e_1 and e_2, then the matrix moves the plane.

The point x = (3, 2) means 3 steps of e_1, then 2 steps of e_2.

x
(3, 2)
Ax
–
0.00 / 13.70 s
Describe this picture

The square grid with the point (3,2)(3,2) drawn as a chain of arrows, tip to tail: three copies of e1\mathbf{e}_1, then two copies of e2\mathbf{e}_2. The grid then moves as in the first picture, and the chain moves with it: it becomes three copies of (2,1)(2,1) followed by two copies of (−1,1)(-1,1), and it ends at (4,5)(4,5). Then, in a corner of the panel, the two row sums appear one after the other, 2⋅3+(−1)⋅2=42\cdot3+(-1)\cdot2=4 and 1⋅3+1⋅2=51\cdot3+1\cdot2=5. The picture has no control.

The chain keeps its instructions, 3 steps then 2 steps, and only the arrows change. So the point lands at

3[21]+2[−11]=[6−23+2]=[45].3\begin{bmatrix}2\\1\end{bmatrix}+2\begin{bmatrix}-1\\1\end{bmatrix}=\begin{bmatrix}6-2\\3+2\end{bmatrix}=\begin{bmatrix}4\\5\end{bmatrix}.

This is what “a matrix times a vector” means. For a vector x=(x1,x2)\mathbf{x}=(x_1,x_2),

Ax=x1a1+x2a2.\mathbf{A}\mathbf{x}=x_1\mathbf{a}_1+x_2\mathbf{a}_2 .

The numbers in x\mathbf{x} are the weights, and the columns of A\mathbf{A} are what they weigh. It is the linear combination of Linear combinations and span, with the columns as the arrows.

One row at a time

There is a second way to get the same answer, and it is the one most people compute by hand. Look at the top number of the answer, 4. It came from 2⋅32\cdot3 in the first column and (−1)⋅2(-1)\cdot2 in the second. Those are the first row of A\mathbf{A}, 2, −12,\,-1, multiplied entry by entry with 3, 23,\,2 and added up.

[2−111][32]=[2⋅3+(−1)⋅21⋅3+1⋅2]=[45].\begin{bmatrix}2&-1\\1&1\end{bmatrix}\begin{bmatrix}3\\2\end{bmatrix}=\begin{bmatrix}2\cdot3+(-1)\cdot2\\1\cdot3+1\cdot2\end{bmatrix}=\begin{bmatrix}4\\5\end{bmatrix}.

Multiply matching entries and add: that is the dot product of the row with x\mathbf{x}, which Length and the dot product studies on its own. So each number that comes out is one row’s dot product with x\mathbf{x}.

To write this for any matrix I need names for the entries. The entry in row pp and column qq is apqa_{pq}, and both count from 1: here a11=2a_{11}=2, a12=−1a_{12}=-1, a21=1a_{21}=1 and a22=1a_{22}=1. Entry pp of the answer y=Ax\mathbf{y}=\mathbf{A}\mathbf{x} is

yp=∑q=1napq xq,y_p=\sum_{q=1}^{n}a_{pq}\,x_q ,

where nn is the number of columns. The columns picture and the rows picture add up the same products, only in a different order. So they always agree.

What makes it linear

Watch the first picture again and look at the grid lines. They stay straight. Lines that were parallel stay parallel. Lines that were evenly spaced stay evenly spaced. And the origin stays where it is. That is what linear means for a map of the plane, and the column rule explains all of it.

The origin first. The point (0,0)(0,0) takes no steps along either arrow, so wherever the arrows go, it stays put:

A0=0 a1+0 a2=0.\mathbf{A}\mathbf{0}=0\,\mathbf{a}_1+0\,\mathbf{a}_2=\mathbf{0}.

Now a grid line. Its points are x\mathbf{x}, x+v\mathbf{x}+\mathbf{v}, x+2v\mathbf{x}+2\mathbf{v} and so on, evenly spaced along a step v\mathbf{v}. The column rule adds weights, so the matrix sends them to Ax\mathbf{A}\mathbf{x}, Ax+Av\mathbf{A}\mathbf{x}+\mathbf{A}\mathbf{v}, Ax+2Av\mathbf{A}\mathbf{x}+2\mathbf{A}\mathbf{v}: again evenly spaced, along the new step Av\mathbf{A}\mathbf{v}. Every grid line in the same direction has the same step, so they stay parallel. Both facts come from one rule, which holds for any vectors x\mathbf{x}, y\mathbf{y} and numbers cc, dd:

A(c x+d y)=c Ax+d Ay.\mathbf{A}(c\,\mathbf{x}+d\,\mathbf{y})=c\,\mathbf{A}\mathbf{x}+d\,\mathbf{A}\mathbf{y}.

The unit square shows it too. Its corners are (0,0)(0,0), (1,0)(1,0), (1,1)(1,1) and (0,1)(0,1). They land at (0,0)(0,0), at a1=(2,1)\mathbf{a}_1=(2,1), at a1+a2=(1,2)\mathbf{a}_1+\mathbf{a}_2=(1,2) and at a2=(−1,1)\mathbf{a}_2=(-1,1). That is the parallelogram in the first picture.

Numbers in, numbers out

A matrix does not have to be square. Its shape is written rows × columns: an m×nm\times n matrix has mm rows and nn columns. There is one column for each number that goes in, so it takes nn numbers in. There is one row for each number that comes out, so it gives mm numbers out.

Here is a 3×23\times2 matrix:

B=[100111].\mathbf{B}=\begin{bmatrix}1&0\\0&1\\1&1\end{bmatrix}.

It sends e1\mathbf{e}_1 to (1,0,1)(1,0,1) and e2\mathbf{e}_2 to (0,1,1)(0,1,1), two arrows in space. So the point (3,2)(3,2) goes to 3 (1,0,1)+2 (0,1,1)=(3,2,5)3\,(1,0,1)+2\,(0,1,1)=(3,2,5). Two numbers go in and three come out. The whole flat plane lands on a tilted flat sheet in space, where the third number is the sum of the first two.

(3, 2)the plane: 2 numbersB(3, 2, 5)213
Fig. The 3×2 matrix B takes the flat plane into space. Every point lands on one tilted sheet, and (3, 2) lands at (3, 2, 5), straight above (3, 2).

Worked example

Take A=[2−111]\mathbf{A}=\begin{bmatrix}2&-1\\1&1\end{bmatrix} and x=(3,2)\mathbf{x}=(3,2).

  1. By columns. Ax=3 (2,1)+2 (−1,1)=(6−2, 3+2)=(4,5)\mathbf{A}\mathbf{x}=3\,(2,1)+2\,(-1,1)=(6-2,\ 3+2)=(4,5).
  2. By rows. First row: 2⋅3+(−1)⋅2=42\cdot3+(-1)\cdot2=4. Second row: 1⋅3+1⋅2=51\cdot3+1\cdot2=5. The same (4,5)(4,5).
  3. The second arrow. Where does (0,1)(0,1) land? It is e2\mathbf{e}_2, so it lands on the second column, (−1,1)(-1,1).
  4. Another point. A (1,−1)=1 (2,1)−1 (−1,1)=(3,0)\mathbf{A}\,(1,-1)=1\,(2,1)-1\,(-1,1)=(3,0). By rows: 2+1=32+1=3 and 1−1=01-1=0.
  5. The origin. A (0,0)=(0,0)\mathbf{A}\,(0,0)=(0,0). A matrix never moves the origin.
  6. Predict first. A matrix has columns (1,0)(1,0) and (1,1)(1,1). Where does (2,3)(2,3) go? Guess from the picture of the two arrows, then check: 2 (1,0)+3 (1,1)=(5,3)2\,(1,0)+3\,(1,1)=(5,3).
  7. Shapes. The 3×23\times2 matrix B\mathbf{B} above takes 2 numbers to 3: (3,2)(3,2) goes to (3,2,5)(3,2,5).

Where you’ll meet this

A stereo crossfeed, which makes headphones sound more like speakers, mixes a little of each channel into the other. With the matrix [0.70.30.30.7]\begin{bmatrix}0.7&0.3\\0.3&0.7\end{bmatrix}, a sound on the left channel only, (1,0)(1,0), comes out as (0.7,0.3)(0.7,0.3): the first column.

A 3-D graphics program moves a model by applying one matrix to every corner of it, many times a second. Every layer of a neural network starts with a matrix times a vector. A phone turns the readings of its motion sensor with a matrix, so that “up” for the sensor matches “up” on the screen.

In signal processing · convolution

A filter in signal processing is a matrix too. Stack shifted copies of the impulse response hh as the columns of a matrix H\mathbf{H}, and filtering the samples x\mathbf{x} is y=Hx\mathbf{y}=\mathbf{H}\mathbf{x}, the column rule of this page. The page Discrete convolution shows that view. One difference in counting: matrix entries count from 1, while samples x[n]x[n] count from 0, so the vector’s entry xqx_q is the sample x[q−1]x[q-1]. A coefficient with one subscript, like aka_k, is a filter coefficient there; two subscripts, apqa_{pq}, always mean a matrix entry.

Reference card

QuantityFormulaNotes
Unit arrowse1=(1,0)\mathbf{e}_1=(1,0), e2=(0,1)\mathbf{e}_2=(0,1)bold, never the number ee
Columnsaq\mathbf{a}_q is where eq\mathbf{e}_q landsread the columns, not the rows
By columnsAx=x1a1+x2a2\mathbf{A}\mathbf{x}=x_1\mathbf{a}_1+x_2\mathbf{a}_2the entries of x\mathbf{x} are weights
By rowsyp=∑q=1napqxqy_p=\sum_{q=1}^{n}a_{pq}x_qone dot product per row
Entriesapqa_{pq}: row pp, column qqboth count from 1
LinearA(cx+dy)=cAx+dAy\mathbf{A}(c\mathbf{x}+d\mathbf{y})=c\mathbf{A}\mathbf{x}+d\mathbf{A}\mathbf{y}straight, parallel, evenly spaced lines
OriginA0=0\mathbf{A}\mathbf{0}=\mathbf{0}never moves
Shapem×nm\times n: nn numbers in, mm outrows × columns

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look