Skip to content

A gallery of linear maps

Turn, scale, stretch, shear, reflect and flatten a picture with six matrices, read each one from its columns, and see why a shift is not linear.

Helps to know firstA matrix moves the plane

Helps to know first
This topic

First, the picture

Six matrices, six ways to move a picture. Watch the letter F turn, grow, stretch, lean, flip and flatten.

Six ways to move a picture

Turn, scale, stretch, shear, reflect, flatten. Read each matrix's columns before it plays.

Six matrices, one after another. Before each one plays, read its columns: they are where e_1 and e_2 will land.

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

One panel with a faint square grid, the two unit arrows and the letter F drawn on the grid. The panel plays six maps in turn. Each starts from the square grid, moves the grid and the F to its end state, and holds there. Its matrix stays in the corner of the panel the whole time, the first column in the colour of e1\mathbf{e}_1 and the second in the colour of e2\mathbf{e}_2. In order: a turn by 30° anticlockwise, [0.866−0.50.50.866]\begin{bmatrix}0.866&-0.5\\0.5&0.866\end{bmatrix}; a scaling by 1.5, [1.5001.5]\begin{bmatrix}1.5&0\\0&1.5\end{bmatrix}; a stretch along the horizontal axis, [2001]\begin{bmatrix}2&0\\0&1\end{bmatrix}; a shear, [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix}; a reflection in the line y=xy=x, [0110]\begin{bmatrix}0&1\\1&0\end{bmatrix}; and a projection onto that line, [0.50.50.50.5]\begin{bmatrix}0.5&0.5\\0.5&0.5\end{bmatrix}. The turn sweeps round. The scaling, the stretch and the projection glide straight; the shear turns a little as it stretches. The reflection folds the plane across a dotted mirror line, the line y=xy=x: halfway through, the F lies flat on that line for a moment, then opens out mirrored. A transport plays, pauses and steps from one map to the next; there is no other control.

Read the columns

In A matrix moves the plane a matrix was the table of where two arrows land. I call those 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. The first column of a matrix is where e1\mathbf{e}_1 lands, and the second column is where e2\mathbf{e}_2 lands.

That one rule lets you read every picture in the gallery from its matrix. Step through the clip and, before each map plays, guess the picture from the two columns.

Turn. A turn by an angle θ\theta anticlockwise moves e1\mathbf{e}_1 round the unit circle to (cos⁡θ,sin⁡θ)(\cos\theta,\sin\theta). The arrow e2\mathbf{e}_2 starts a quarter turn further on, and it lands at (−sin⁡θ,cos⁡θ)(-\sin\theta,\cos\theta), a quarter turn ahead of e1\mathbf{e}_1‘s new place. So

Arot(θ)=[cos⁡θ−sin⁡θsin⁡θcos⁡θ].\mathbf{A}_\text{rot}(\theta)=\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}.

The minus sign sits at the top right because e2\mathbf{e}_2 swings to the left. For 30°, which is π/6≈0.5236\pi/6\approx0.5236 rad, the columns are (0.866, 0.5)(0.866,\,0.5) and (−0.5, 0.866)(-0.5,\,0.866).

Scale. [1.5001.5]\begin{bmatrix}1.5&0\\0&1.5\end{bmatrix} makes both arrows 1.5 times as long. The F grows and keeps its shape.

Stretch. [2001]\begin{bmatrix}2&0\\0&1\end{bmatrix} doubles e1\mathbf{e}_1 and leaves e2\mathbf{e}_2 alone. The F becomes twice as wide and just as tall.

Shear. Ashear=[1101]\mathbf{A}_\text{shear}=\begin{bmatrix}1&1\\0&1\end{bmatrix} keeps e1\mathbf{e}_1 and sends e2\mathbf{e}_2 to (1,1)(1,1). Each row of the grid slides sideways by its height, and the F leans over.

Reflect. Arefl=[0110]\mathbf{A}_\text{refl}=\begin{bmatrix}0&1\\1&0\end{bmatrix} swaps the two arrows. The line y=xy=x acts as a mirror, and the F comes out back to front.

Project. Aproj=[0.50.50.50.5]\mathbf{A}_\text{proj}=\begin{bmatrix}0.5&0.5\\0.5&0.5\end{bmatrix} sends both arrows to the same place, (0.5, 0.5)(0.5,\,0.5). Every point (x,y)(x,y) goes to (x+y2,x+y2)\big(\tfrac{x+y}{2},\tfrac{x+y}{2}\big), the point of the line y=xy=x straight across from it at a right angle. The whole F is flattened onto the line.

Reading also works backwards. Draw where the two arrows should land, and their coordinates, written as columns, are the matrix.

The two rules

Every map in the gallery keeps grid lines straight, parallel and evenly spaced, and keeps the origin in place. Written as rules, a map TT of the plane is linear when, for all vectors x\mathbf{x}, y\mathbf{y} and every number cc,

T{x+y}=T{x}+T{y},T{c x}=c T{x}.\begin{aligned} T\{\mathbf{x}+\mathbf{y}\}&=T\{\mathbf{x}\}+T\{\mathbf{y}\},\\ T\{c\,\mathbf{x}\}&=c\,T\{\mathbf{x}\}. \end{aligned}

The first rule says adding first and mapping first give the same answer. The second says the same for scaling. I write a map with braces, T{⋅}T\{\cdot\}, as the signal processing course writes a system, and the two rules are the same there.

These two rules are why the columns are enough. Every vector is a combination of the unit arrows, x=x1e1+x2e2\mathbf{x}=x_1\mathbf{e}_1+x_2\mathbf{e}_2. Apply both rules:

T{x}=x1 T{e1}+x2 T{e2}.T\{\mathbf{x}\}=x_1\,T\{\mathbf{e}_1\}+x_2\,T\{\mathbf{e}_2\}.

So once you know where e1\mathbf{e}_1 and e2\mathbf{e}_2 land, you know where everything lands. The matrix of TT is those two landing places side by side:

A=[T{e1}T{e2}].\mathbf{A}=\begin{bmatrix}T\{\mathbf{e}_1\}&T\{\mathbf{e}_2\}\end{bmatrix}.

Here is a check on the shear. Ashear\mathbf{A}_\text{shear} sends (1,1)(1,1) to (2,1)(2,1). Doubling the input, (2,2)(2,2) goes to (4,2)(4,2), which is twice (2,1)(2,1), as the second rule says.

In signal processing · superposition

System properties, in the signal processing course, calls the first rule additivity and the second homogeneity; together they are superposition. A linear system of signals and a linear map of the plane obey exactly the same two rules.

Not linear: a shift

Here is a move that looks harmless: slide the whole plane one step to the right. Every point x\mathbf{x} goes to x+(1,0)\mathbf{x}+(1,0). Watch what the grid does.

A shift is not linear

Every point x goes to x + (1, 0).

The square grid, with its origin marked.

the origin is now at
(0, 0)
0.00 / 5.00 s
Describe this picture

The square grid with the origin marked and the unit square shaded. The whole grid slides one step to the right, by (1,0)(1,0), and holds. The grid lines stay straight and evenly spaced, but the mark for the origin moves to (1,0)(1,0), and a ring marks where it was. A readout gives where the origin is now. There is no control.

The grid lines stay straight, so the shift looks linear. But watch the origin: it moves, and a linear map never moves the origin. Both rules fail. Take T{x}=x+(1,0)T\{\mathbf{x}\}=\mathbf{x}+(1,0):

  • T{0}=(1,0)T\{\mathbf{0}\}=(1,0), not 0\mathbf{0}. With c=0c=0 the second rule would need T{0}=0⋅T{0}=0T\{\mathbf{0}\}=0\cdot T\{\mathbf{0}\}=\mathbf{0}.
  • T{x+y}=x+y+(1,0)T\{\mathbf{x}+\mathbf{y}\}=\mathbf{x}+\mathbf{y}+(1,0) gets one shift, but T{x}+T{y}=x+y+(2,0)T\{\mathbf{x}\}+T\{\mathbf{y}\}=\mathbf{x}+\mathbf{y}+(2,0) gets two.

No 2×2 matrix can do a shift, because every matrix sends 0\mathbf{0} to 0\mathbf{0}. Matrices in computer graphics shows the way round this.

Watch out

In school algebra, a “linear function” is a straight-line graph such as y=2x+1y=2x+1. In linear algebra that function is not linear: at 0 it gives 1, not 0, and adding first gives a different answer, since 2(1+1)+1=52(1+1)+1=5 while (2⋅1+1)+(2⋅1+1)=6(2\cdot1+1)+(2\cdot1+1)=6. Only y=2xy=2x, with no added constant, is linear here.

Maps of space

In space a matrix has three columns: where e1=(1,0,0)\mathbf{e}_1=(1,0,0), e2=(0,1,0)\mathbf{e}_2=(0,1,0) and e3=(0,0,1)\mathbf{e}_3=(0,0,1) land. Take a quarter turn about the vertical axis, the third one. It turns e1\mathbf{e}_1 to (0,1,0)(0,1,0) and e2\mathbf{e}_2 to (−1,0,0)(-1,0,0), and it leaves e3\mathbf{e}_3, the axis itself, where it is:

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

It sends the point (1,2,3)(1,2,3) to

A[123]=1[010]+2[−100]+3[001]=[−213].\begin{aligned} \mathbf{A}\begin{bmatrix}1\\2\\3\end{bmatrix}&=1\begin{bmatrix}0\\1\\0\end{bmatrix}+2\begin{bmatrix}-1\\0\\0\end{bmatrix}+3\begin{bmatrix}0\\0\\1\end{bmatrix}\\ &=\begin{bmatrix}-2\\1\\3\end{bmatrix}. \end{aligned}

The first two numbers turn exactly as in the plane, and the height stays 3.

123(1, 2, 3)(−2, 1, 3)
Fig. A quarter turn about the vertical axis takes (1, 2, 3) to (−2, 1, 3). The height stays 3; the dashed shadows on the floor turn from (1, 2) to (−2, 1).

Worked example

1. From a picture to a matrix. A map sends e1\mathbf{e}_1 to (0,2)(0,2) and e2\mathbf{e}_2 to (−1,0)(-1,0). Its columns are those two landing places:

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

It sends (3,1)(3,1) to 3 (0,2)+1 (−1,0)=(−1,6)3\,(0,2)+1\,(-1,0)=(-1,6). By rows: 0⋅3+(−1)⋅1=−10\cdot3+(-1)\cdot1=-1 and 2⋅3+0⋅1=62\cdot3+0\cdot1=6. In words, this map turns everything a quarter turn anticlockwise and then doubles every height: the turn takes e1\mathbf{e}_1 to (0,1)(0,1), which doubles to (0,2)(0,2), and e2\mathbf{e}_2 to (−1,0)(-1,0), whose height is 0.

2. The shift fails. T{x}=x+(1,0)T\{\mathbf{x}\}=\mathbf{x}+(1,0) gives T{0}=(1,0)≠0T\{\mathbf{0}\}=(1,0)\ne\mathbf{0}, so it is not linear.

3. The shear passes the scaling rule. Ashear(2,2)=(4,2)=2 (2,1)=2 Ashear(1,1)\mathbf{A}_\text{shear}(2,2)=(4,2)=2\,(2,1)=2\,\mathbf{A}_\text{shear}(1,1).

4. A reflection you write yourself. The mirror in the horizontal axis keeps e1\mathbf{e}_1 and flips e2\mathbf{e}_2 to (0,−1)(0,-1), so its matrix is [100−1]\begin{bmatrix}1&0\\0&-1\end{bmatrix}.

5. A turn by 30°. It sends (1,0)(1,0) to its first column, (0.866, 0.5)(0.866,\,0.5).

Predict before you watch the gallery again: which of the six maps can’t be undone? The projection. It sends a whole line of points to each single point of y=xy=x, so nothing can tell where a point started.

Where you’ll meet this

Image editors. Rotate, resize, skew and flip are these matrices, applied to the position of every pixel. Skew is the shear, and flip is a reflection.

Turning a phone. A phone’s motion sensor reports gravity in the sensor’s own axes. Turn the phone a quarter turn and the reading (0.3, 9.7)(0.3,\,9.7) m/s² becomes (−9.7, 0.3)(-9.7,\,0.3) m/s² in the screen’s axes: Arot(θ)\mathbf{A}_\text{rot}(\theta) with θ=π/2\theta=\pi/2, a quarter turn, applied to the reading.

Complex numbers. Multiplying a complex number a+jba+jb by cos⁡θ+jsin⁡θ\cos\theta+j\sin\theta gives (acos⁡θ−bsin⁡θ)+j(asin⁡θ+bcos⁡θ)(a\cos\theta-b\sin\theta)+j(a\sin\theta+b\cos\theta). That is Arot(θ)\mathbf{A}_\text{rot}(\theta) applied to the point (a,b)(a,b), the rotate-and-scale picture of Complex numbers for signals in the signal processing course.

Reference card

QuantityFormulaNotes
Matrix of a mapA=[T{e1}T{e2}]\mathbf{A}=\begin{bmatrix}T\{\mathbf{e}_1\}&T\{\mathbf{e}_2\}\end{bmatrix}columns: where the unit arrows land
TurnArot(θ)=[cos⁡θ−sin⁡θsin⁡θcos⁡θ]\mathbf{A}_\text{rot}(\theta)=\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}anticlockwise by θ\theta
Scale, stretch[1.5001.5]\begin{bmatrix}1.5&0\\0&1.5\end{bmatrix}, [2001]\begin{bmatrix}2&0\\0&1\end{bmatrix}numbers on the diagonal stretch the axes
ShearAshear=[1101]\mathbf{A}_\text{shear}=\begin{bmatrix}1&1\\0&1\end{bmatrix}rows slide sideways by their height
Reflection in y=xy=xArefl=[0110]\mathbf{A}_\text{refl}=\begin{bmatrix}0&1\\1&0\end{bmatrix}swaps the two arrows
Projection onto y=xy=xAproj=[0.50.50.50.5]\mathbf{A}_\text{proj}=\begin{bmatrix}0.5&0.5\\0.5&0.5\end{bmatrix}flattens the plane; can’t be undone
LinearT{x+y}=T{x}+T{y}T\{\mathbf{x}+\mathbf{y}\}=T\{\mathbf{x}\}+T\{\mathbf{y}\}, T{c x}=c T{x}T\{c\,\mathbf{x}\}=c\,T\{\mathbf{x}\}origin stays put
Shiftx↦x+(1,0)\mathbf{x}\mapsto\mathbf{x}+(1,0)not linear: it moves the origin

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