Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3.3: Linear transformations

You may have noticed that, in Chapter 3.2, we thought of multiplying a matrix by a vector as transforming the vector in some describable way. Some matrices stretched our vectors, some rotated them, and some sent them all to a line.

What type of transformation does matrix-vector multiplication describe? To answer that question, we first need to agree on what a function is.


Functions

You have probably seen functions written as f(x)=x2f(x)=x^2 or f(x)=2x+1f(x)=2x+1. In each case, we put a number in and get a number out. But a function’s inputs and outputs don’t have to be individual numbers!

For example, suppose A={1,2,3,4,5}A=\{1,2,3,4,5\} and B={1,2,3,4,5}B=\{1,2,3,4,5\}. We can define a function just by listing what it does:

Input aaOutput f(a)f(a)
12
24
32
45
54

This table tells us everything about ff. For instance, f(1)=2f(1)=2 and f(3)=2f(3)=2. It’s fine for two different inputs to give the same output.

Notice that neither 1 nor 3 is ever produced, even though both belong to BB. Not every element of the codomain needs to be pointed to.

Here’s another way to draw the same function. Follow the arrow from an input to see its output.

Loading...

A rule instead of a table

We could define a different function g:A→Bg:A\to B by the rule, or formula,

g(a)=6−ag(a) = 6-a

Then g(1)=5g(1)=5, g(2)=4g(2)=4, and so on. A table and a rule are two ways of telling us what a function does. Of course, rules are more concise, and work even when there are infinitely many possible inputs.

Vectors as inputs

Now let’s try a function whose inputs and outputs are vectors:

F:R2→R2,F([xy])=[x+2y].F:\mathbb R^2\to\mathbb R^2,\qquad F\left(\begin{bmatrix}x\\y\end{bmatrix}\right)=\begin{bmatrix}x+2\\y\end{bmatrix}.

In words, FF adds 2 to the first entry of the input vector and leaves the second entry alone. For example,

F([3−1])=[5−1],F([00])=[20].F\left(\begin{bmatrix}3\\-1\end{bmatrix}\right)=\begin{bmatrix}5\\-1\end{bmatrix},\qquad F\left(\begin{bmatrix}0\\0\end{bmatrix}\right)=\begin{bmatrix}2\\0\end{bmatrix}.

The domain is R2\mathbb R^2 and the codomain is R2\mathbb R^2. There are two entries in each input, but the whole vector is one input to FF.

We can think of FF as moving every point two units to the right. That certainly transforms our vectors. But is it the kind of transformation we can describe using a matrix?


Linear transformations

Linear transformations are a very specific type of function. The two properties in the definition should look familiar from Chapter 3.2.

The first property says that adding two inputs and then applying TT gives the same result as applying TT to each input and adding the outputs. The second says that scaling an input scales its output by the same amount.

Together, they tell us that

T(au⃗+bv⃗)=aT(u⃗)+bT(v⃗).T(a\vec u+b\vec v)=aT(\vec u)+bT(\vec v).

That is, we can pull the coefficients outside the function, just as we did with matrix-vector multiplication.

Functions of one number

We can think of a real number as a vector with one entry, so functions R→R\mathbb R\to\mathbb R can be linear transformations too. For instance, take f(x)=3xf(x)=3x. Then

f(u+v)=3(u+v)=3u+3v=f(u)+f(v),f(cu)=3cu=cf(u).f(u+v)=3(u+v)=3u+3v=f(u)+f(v),\qquad f(cu)=3cu=cf(u).

Its domain and codomain are both R\mathbb R, and both algebraic properties hold, so ff is a linear transformation.

What about g(x)=3x+1g(x)=3x+1? Its graph is a line, but gg is not a linear transformation! For example,

g(1+1)=7,g(1)+g(1)=4+4=8.g(1+1)=7,\qquad g(1)+g(1)=4+4=8.

The addition property fails; one counterexample is all we need to show g(x)g(x) is not a linear transformation. It is an affine transformation, which is a “shifted” linear transformation (just as an affine line is a line that doesn’t necessarily go through the origin).

The zero vector

If TT is a linear transformation, setting c=0c=0 in the scaling property gives

T(0⃗)=T(0v⃗)=0T(v⃗)=0⃗.T(\vec0)=T(0\vec v)=0T(\vec v)=\vec0.

So every linear transformation sends the zero vector to the zero vector. Our earlier function FF, which adds 2 to the first entry, fails this check. It is a function, but it isn’t a linear transformation.

Passing this check doesn’t automatically make a function a linear transformation. For example, h(x)=x2h(x)=x^2 sends 0 to 0, but h(2⋅1)=4h(2\cdot1)=4 while 2h(1)=22h(1)=2.


Matrices as linear transformations

More precisely, for every linear transformation T:Rd→RnT:\mathbb R^d\to\mathbb R^n, there is a unique n×dn\times d matrix AA such that

T(x⃗)=Ax⃗for every x⃗∈Rd.T(\vec x)=A\vec x\qquad\text{for every }\vec x\in\mathbb R^d.

Conversely, multiplying by any fixed n×dn\times d matrix defines a linear transformation from Rd\mathbb R^d to Rn\mathbb R^n.

Let’s see how to find that matrix. The rule

T([xy])=[x+yx]T\left(\begin{bmatrix}x\\y\end{bmatrix}\right)=\begin{bmatrix}x+y\\x\end{bmatrix}

can be written as

T([xy])=[1110][xy].T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) =\begin{bmatrix}1&1\\1&0\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}.

The first row records how to compute the first output entry: 1x+1y1x+1y. The second records how to compute the second output entry: 1x+0y1x+0y.

Here are two more examples:

[xy]⟼[xyx+y]uses[100111],[xyz]⟼[x−z2y]uses[10−1020].\begin{aligned} \begin{bmatrix}x\\y\end{bmatrix}\longmapsto\begin{bmatrix}x\\y\\x+y\end{bmatrix} &\qquad\text{uses}\qquad \begin{bmatrix}1&0\\0&1\\1&1\end{bmatrix},\\[6pt] \begin{bmatrix}x\\y\\z\end{bmatrix}\longmapsto\begin{bmatrix}x-z\\2y\end{bmatrix} &\qquad\text{uses}\qquad \begin{bmatrix}1&0&-1\\0&2&0\end{bmatrix}. \end{aligned}

Notice the shapes: 3×23\times2 in the first example, 2×32\times3 in the second. Each input entry needs a column, and each output entry needs a row.

Think of a linear transformation as a machine. A vector v⃗\vec v goes into the machine, and what comes out is Av⃗A\vec v.

Loading...

Basis vectors determine the matrix

I’m thinking of a 2×22\times2 matrix AA. I won’t tell you its entries, but I’ll give you two clues:

A[10]=[2−1],A[01]=[34].A\begin{bmatrix}1\\0\end{bmatrix}=\begin{bmatrix}2\\-1\end{bmatrix},\qquad A\begin{bmatrix}0\\1\end{bmatrix}=\begin{bmatrix}3\\4\end{bmatrix}.

Can you identify all of AA from just these two outputs? Take a moment to think about what each multiplication tells you.

Write the unknown matrix as A=[abcd]A=\begin{bmatrix}a&b\\c&d\end{bmatrix}. Then

[abcd][10]=[ac],[abcd][01]=[bd].\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}1\\0\end{bmatrix} =\begin{bmatrix}a\\c\end{bmatrix},\qquad \begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}0\\1\end{bmatrix} =\begin{bmatrix}b\\d\end{bmatrix}.

The first input selects the first column: one copy of that column and zero copies of the other. The second input selects the second column. So the two clues reveal every entry:

A=[23−14].A=\begin{bmatrix}2&3\\-1&4\end{bmatrix}.

Recall that e⃗1=[10]\vec e_1=\begin{bmatrix}1\\0\end{bmatrix} and e⃗2=[01]\vec e_2=\begin{bmatrix}0\\1\end{bmatrix} are just our standard basis vectors. Sending these two vectors through a matrix reveals its two columns.

In R2\mathbb R^2, every vector can be written using the standard basis vectors:

[xy]=x[10]⏟e⃗1+y[01]⏟e⃗2.\begin{bmatrix}x\\y\end{bmatrix} =x\underbrace{\begin{bmatrix}1\\0\end{bmatrix}}_{\vec e_1} +y\underbrace{\begin{bmatrix}0\\1\end{bmatrix}}_{\vec e_2}.

If TT is a linear transformation, then

T([xy])=xT(e⃗1)+yT(e⃗2).T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) =xT(\vec e_1)+yT(\vec e_2).

This is a linear combination of two fixed vectors. We already know how to write that as a matrix-vector product: put the two vectors into the columns of a matrix!

The same argument works in Rd\mathbb R^d:

T(x⃗)=x1T(e⃗1)+⋯+xdT(e⃗d).T(\vec x)=x_1T(\vec e_1)+\cdots+x_dT(\vec e_d).

For example, suppose a linear transformation satisfies

T(e⃗1)=T([10])=[2−1],T(e⃗2)=T([01])=[34].T(\vec e_1)=T\left(\begin{bmatrix}1\\0\end{bmatrix}\right)=\begin{bmatrix}2\\-1\end{bmatrix},\qquad T(\vec e_2)=T\left(\begin{bmatrix}0\\1\end{bmatrix}\right)=\begin{bmatrix}3\\4\end{bmatrix}.

Without knowing anything else about TT, we can write

A=[23−14],T([3−2])=3[2−1]−2[34]=[0−11].A=\begin{bmatrix}2&3\\-1&4\end{bmatrix},\qquad T\left(\begin{bmatrix}3\\-2\end{bmatrix}\right) =3\begin{bmatrix}2\\-1\end{bmatrix}-2\begin{bmatrix}3\\4\end{bmatrix} =\begin{bmatrix}0\\-11\end{bmatrix}.

Just two outputs determined what happens to every vector in R2\mathbb R^2. In Chapter 3.4, we’ll use this idea to understand what different matrices do geometrically.