The Matrix of a Linear Map

The last page ended with a promise: a linear map is decided by where it sends a basis. So to hand someone a linear map you don't need a formula, only a short list of vectors. This page writes that list down in the most useful way there is, as a matrix, and then learns to read the same map in other bases, where its matrix can look completely different.

On the Geometry page, every matrix was a move of the plane, and on Null Space & Range every one of those moves turned out to be a linear map. This page goes the other way. Start with any linear map, and find the matrix that does it. The trick is to watch where the arrows $e_1$, $e_2$ (and $e_3$) land.

The Standard Matrix

On Null Space & Range, the images of a basis decided the whole map. The standard basis is the friendliest basis there is, so start there.

That figure is the whole page in one picture: put $T(e_1), T(e_2), \ldots$ side by side as columns.

Let $T\colon \R^n \to \R^m$ be linear. The standard matrix of $T$, written $[T]$, is the $m \times n$ matrix whose $j$-th column is $T(e_j)$:

$$[T] = \begin{pmatrix} | & | & & | \\ T(e_1) & T(e_2) & \cdots & T(e_n) \\ | & | & & | \end{pmatrix}.$$

Let $T$ be a linear map from $\R^2$ or $\R^3$ to $\R^2$ or $\R^3$. The standard matrix of $T$, written $[T]$, is the matrix whose columns are $T(e_1)$, $T(e_2)$ (and $T(e_3)$), in that order.

The Geometry page started from a matrix and found its columns waiting at $Ae_1$ and $Ae_2$. This theorem starts from the map and says the trip always works the other way too.

Let $T\colon \R^n \to \R^m$ be linear. Then $T(x) = [T]\,x$ for every $x$ in $\R^n$, and $[T]$ is the only matrix that does this: if $A$ is an $m \times n$ matrix with $T(x) = Ax$ for every $x$, then $A = [T]$.

Show proof

Write $x = x_1e_1 + \cdots + x_ne_n$. By linearity, $T(x) = x_1T(e_1) + \cdots + x_nT(e_n)$, and by the column picture that combination of the columns of $[T]$ is $[T]x$.

If also $T(x) = Ax$ for every $x$, then $Ae_j = T(e_j)$ for each $j$. But $Ae_j$ is the $j$-th column of $A$ (Geometry of Linear Maps), so $A$ and $[T]$ have the same columns, and $A = [T]$. $\blacksquare$

Every linear map $T$ from $\R^2$ or $\R^3$ to $\R^2$ or $\R^3$ is a matrix: $T(x) = [T]\,x$ for every input $x$. And no other matrix does the job.

Why it's true (picture)

This is a visual argument, not a formal proof. Every input is a walk along $e_1$, $e_2$, $e_3$: $x_1$ steps of the first, $x_2$ of the second, $x_3$ of the third. A linear map has to send that walk to the same walk along $T(e_1)$, $T(e_2)$, $T(e_3)$. Walking $x_1$ of the first column, $x_2$ of the second, and $x_3$ of the third is exactly what $[T]x$ computes (the column picture from the Matrices page). And a different matrix would have a different column somewhere, so it would send that $e_j$ to the wrong place.

The full proof is in the n version.

So matrices and linear maps between these spaces are the same list, written two ways. Here's how to go from a formula to the matrix.

Let $T\colon \R^2 \to \R^3$ be defined by $T(a_1, a_2) = (2a_1 - a_2, \ a_1, \ 3a_2)$. Find $[T]$.


Apply $T$ to each standard vector:

$$T(e_1) = T(1, 0) = (2, 1, 0), \qquad T(e_2) = T(0, 1) = (-1, 0, 3).$$

Stand them up as columns:

$$[T] = \begin{pmatrix} 2 & -1 \\ 1 & 0 \\ 0 & 3 \end{pmatrix}.$$

Notice the shape: $T$ goes from $\R^2$ to $\R^3$, and the matrix is $3 \times 2$. Rows match the space you land in, columns match the space you start from.

With a formula there's a shortcut: the coefficients of $a_1$ form column $1$, the coefficients of $a_2$ form column $2$, and so on. Read the formula down, not across.

Columns, not rows. The images of the basis vectors go in down the columns. Putting $T(e_1)$ across the top row is the most common mistake on this page, and it gives you the transpose: right numbers, wrong places. Watch the gaps too: in $T(a_1, a_2, a_3) = (a_1 - 2a_3, \ldots)$ the first row is $1, 0, -2$, with a $0$ for the missing $a_2$.

Sometimes there's no formula at all, just the images of some other basis. Then the columns take one more step.

A linear map $T\colon \R^2 \to \R^2$ has $T(1, 1) = (2, 1)$ and $T(1, 2) = (3, 0)$. Find $[T]$.


The columns are $T(e_1)$ and $T(e_2)$, so first write $e_1$ and $e_2$ with the vectors you know. Solving $a(1, 1) + b(1, 2) = (1, 0)$ gives $a = 2$, $b = -1$, and solving it for $(0, 1)$ gives $a = -1$, $b = 1$:

$$e_1 = 2(1, 1) - (1, 2), \qquad e_2 = -(1, 1) + (1, 2).$$

Now linearity carries the same combinations across:

$$\begin{aligned} T(e_1) &= 2(2, 1) - (3, 0) = (1, 2), \\ T(e_2) &= -(2, 1) + (3, 0) = (1, -1). \end{aligned}$$ $$[T] = \begin{pmatrix} 1 & 1 \\ 2 & -1 \end{pmatrix}.$$

Check: $[T](1, 1) = (1 + 1, \ 2 - 1) = (2, 1)$. It agrees with what we were told.

The same two walks, in the inputs and in the outputs:

The step people skip is the first one.

Don't stand $T(1, 1)$ and $T(1, 2)$ up as the columns. They're true facts about $T$, but the columns of $[T]$ have to be the images of $e_1$ and $e_2$, and those take the extra step.

Your turn. In free response, type the matrix row by row, with commas between entries and a semicolon between rows, like 2, -1; 1, 0; 0, 3.

Loading practice engine...

The Matrix in Other Bases

The standard matrix describes everything in the coordinates of $e_1, e_2, \ldots$. But a basis is a choice, and some choices make a map much easier to read.

A basis $\beta = \{u_1, \ldots, u_k\}$ gives every vector one address, its coordinate vector $[x]_\beta$: the coefficients of $x$ along $u_1, \ldots, u_k$, in that order. Order matters: $(5, 1) = 3(1, 1) + 2(1, -1)$, so $[(5, 1)]_\beta = (3, 2)$ for $\beta = \{(1, 1), (1, -1)\}$, but $(2, 3)$ for $\{(1, -1), (1, 1)\}$.

The matrix of a map in other bases follows the same recipe as before, with one more step: apply $T$ to each basis vector, then write the answer in the output basis's coordinates.

Let $\V$ and $\W$ be finite-dimensional vector spaces with ordered bases $\beta = \{v_1, \ldots, v_n\}$ and $\gamma = \{w_1, \ldots, w_m\}$, and let $T\colon \V \to \W$ be linear. The matrix representation of $T$ in $\beta$ and $\gamma$ is the $m \times n$ matrix $[T]_\beta^\gamma$ whose $j$-th column is $[T(v_j)]_\gamma$. When $\V = \W$ and $\beta = \gamma$, we write $[T]_\beta$.

Let $T$ be a linear map from $\R^2$ or $\R^3$ to $\R^2$ or $\R^3$, let $\beta = \{v_1, v_2, \ldots\}$ be a basis of the inputs, and let $\gamma$ be a basis of the outputs. The matrix representation $[T]_\beta^\gamma$ is the matrix whose $j$-th column is $[T(v_j)]_\gamma$: apply $T$ to the $j$-th arrow of $\beta$, then write the answer in $\gamma$-coordinates. When the inputs and outputs are the same space and $\beta = \gamma$, we write $[T]_\beta$.

With $\beta$ and $\gamma$ the standard bases, every vector is its own coordinate vector, and this is the standard matrix again. Here is the definition at work on $T(a_1, a_2) = (2a_1, \ a_1 + a_2)$ with $\beta = \{(1, 1), (1, -1)\}$ on both sides.

Now one where the basis does something useful.

Let $T\colon \R^2 \to \R^2$ be defined by $T(a_1, a_2) = (a_1 + 2a_2, \ 2a_1 + a_2)$, and let $\beta = \{(1, 1), (1, -1)\}$. Find $[T]_\beta$ and compare it with $[T]$.


Apply $T$ to each vector of $\beta$ and write the answer in $\beta$-coordinates:

$$\begin{aligned} T(1, 1) &= (3, 3) = 3(1, 1) + 0(1, -1), \\ T(1, -1) &= (-1, 1) = 0(1, 1) + (-1)(1, -1). \end{aligned}$$

So the columns are $(3, 0)$ and $(0, -1)$:

$$[T]_\beta = \begin{pmatrix} 3 & 0 \\ 0 & -1 \end{pmatrix}, \qquad\text{while}\qquad [T] = \begin{pmatrix} 1 & 2 \\ 2 & 1 \end{pmatrix}.$$

Same map, two very different matrices. In $\beta$, the matrix says exactly what $T$ does: stretch $(1, 1)$ by $3$ and flip $(1, -1)$.

One step in that example is easy to skip.

When the output basis isn't standard, there's an extra step that's easy to skip: $T(v_j)$ has to be rewritten in its coordinates before it becomes a column. Above, $T(1, 1) = (3, 3)$, but the column is $(3, 0)$, not $(3, 3)$. A matrix only means something together with its bases. (Other books label the same matrix $[T]_{\beta,\gamma}$, or Rep_{B,D}(h) in Hefferon's book: same columns, different label.)

Flip between the two bases: the map never changes, only the grid you describe it on.

Same Map, Two Matrices

That basis was handed to you. Now find good bases yourself: drag $v_1$ and $v_2$ until the matrix does what each mission asks.

Find a Good Basis

A basis that makes the matrix diagonal, like the second mission's, is the holy grail. Finding one on purpose, not by dragging, is what eigenvectors are for.

Your turn. Type the matrix row by row, like 6, 9; -3, -5.

Loading practice engine...

A matrix that describes a map should also be able to run it. It can, as long as you feed it coordinates in the right basis.

Let $T$ be linear, with an ordered basis $\beta$ for its domain and an ordered basis $\gamma$ for its codomain. Then for every $x$ in the domain,

$$[T(x)]_\gamma = [T]_\beta^\gamma\,[x]_\beta.$$
Show proof

Let $\beta = \{v_1, \ldots, v_n\}$ and $[x]_\beta = (c_1, \ldots, c_n)$, so $x = c_1v_1 + \cdots + c_nv_n$ and $T(x) = c_1T(v_1) + \cdots + c_nT(v_n)$. Coordinates respect sums and multiples (Bases & Dimension), so

$$[T(x)]_\gamma = c_1[T(v_1)]_\gamma + \cdots + c_n[T(v_n)]_\gamma.$$

The $[T(v_j)]_\gamma$ are the columns of $[T]_\beta^\gamma$, so by the column picture the right side is $[T]_\beta^\gamma (c_1, \ldots, c_n) = [T]_\beta^\gamma [x]_\beta$. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. $[x]_\beta$ is a walk along the $\beta$ grid. $T$ sends each step along $v_j$ to a step along $T(v_j)$, and column $j$ says what that step is in $\gamma$'s grid. So the image walk is "$c_1$ of column $1$, plus $c_2$ of column $2$, plus …", which is the matrix times $[x]_\beta$. Here it is with the diagonal example: $x = (2, 0)$ is $1v_1 + 1v_2$.

The full proof is in the n version.

The bases can be different on the two sides, and the spaces can be different sizes. Here's a shadow map from space to the floor, described with a slanted basis on each side.

Let $\pi\colon \R^3 \to \R^2$ be $\pi(x, y, z) = (x, y)$, with $\beta = \{(1, 0, 0), (1, 1, 0), (0, 1, 1)\}$ and $\gamma = \{(2, 1), (1, 1)\}$. Find $[\pi]_\beta^\gamma$, and use it to find $\pi(2, 3, 1)$.


The images of $\beta$ are $(1, 0)$, $(1, 1)$, and $(0, 1)$. Write each in $\gamma$-coordinates by solving $a(2, 1) + b(1, 1)$:

$$(1, 0) = 1(2, 1) - 1(1, 1), \quad (1, 1) = 0(2, 1) + 1(1, 1), \quad (0, 1) = -1(2, 1) + 2(1, 1).$$ $$[\pi]_\beta^\gamma = \begin{pmatrix} 1 & 0 & -1 \\ -1 & 1 & 2 \end{pmatrix}.$$

Three columns for the three input dimensions, two rows for the two output dimensions. Now run it. In $\beta$, $(2, 3, 1) = 0(1, 0, 0) + 2(1, 1, 0) + 1(0, 1, 1)$, so $[x]_\beta = (0, 2, 1)$ and

$$[\pi(x)]_\gamma = \begin{pmatrix} 1 & 0 & -1 \\ -1 & 1 & 2 \end{pmatrix}\begin{pmatrix} 0 \\ 2 \\ 1 \end{pmatrix} = \begin{pmatrix} -1 \\ 4 \end{pmatrix}.$$

Back in ordinary coordinates: $-1(2, 1) + 4(1, 1) = (2, 3)$. That's the shadow of $(2, 3, 1)$, as it should be.

Here the slanted bases made the work harder, not easier. Usually you'd use the standard matrix for a map like this. The point is that it always works, and later pages pick the bases that make it easy.

Adding and Scaling Linear Maps

Functions with the same inputs and outputs can be added and scaled just like vectors: do it output by output.

Let $T$ and $U$ be functions with the same domain and the same codomain (a vector space), and let $a$ be a number. The sum $T + U$ and the scalar multiple $aT$ are the functions given by $(T + U)(x) = T(x) + U(x)$ and $(aT)(x) = aT(x)$ for every $x$ in the domain.

So to add two maps, add their outputs.

Let $T(a_1, a_2) = (a_1 + 3a_2, \ -a_1)$ and $U(a_1, a_2) = (a_2, \ 2a_1 - a_2)$. Find $(T + U)(1, 2)$ and $(2T)(1, 2)$.


Work output by output: $T(1, 2) = (7, -1)$ and $U(1, 2) = (2, 0)$, so

$$(T + U)(1, 2) = (7, -1) + (2, 0) = (9, -1), \qquad (2T)(1, 2) = 2(7, -1) = (14, -2).$$

Those are just functions. The good news is that they stay linear.

If $T$ and $U$ are linear, with the same domain and codomain, and $a$ is a number, then $aT + U$ is linear.

Show proof

Let $x, y$ be in the domain and $c \in \R$. Then

$$\begin{aligned} (aT + U)(cx + y) &= aT(cx + y) + U(cx + y) \\ &= a[cT(x) + T(y)] + cU(x) + U(y) \\ &= c[aT(x) + U(x)] + [aT(y) + U(y)] \\ &= c(aT + U)(x) + (aT + U)(y). \end{aligned}$$

So $aT + U$ is linear (the one-line test). $\blacksquare$

Why it's true (picture)

This is a short visual argument, not a formal proof. $T$ sends the parallelogram on $x$ and $y$ to the parallelogram on $T(x)$ and $T(y)$, and $U$ does the same with its own parallelogram. Stretch the first by $a$ and add the two corner by corner: the corners still add up, so the result is a parallelogram on $(aT + U)(x)$ and $(aT + U)(y)$, with $(aT + U)(x + y)$ at the far corner. Stretching an input works the same way.

The full proof is in the n version.

And the matrices play along perfectly: the matrix of a sum is the sum of the matrices.

Let $T$ and $U$ be linear maps with the same domain and codomain, with ordered bases $\beta$ for the domain and $\gamma$ for the codomain, and let $a$ be a number. Then

$$[T + U]_\beta^\gamma = [T]_\beta^\gamma + [U]_\beta^\gamma \qquad\text{and}\qquad [aT]_\beta^\gamma = a[T]_\beta^\gamma.$$

In particular, $[T + U] = [T] + [U]$ and $[aT] = a[T]$ for standard matrices.

Show proof

Let $\beta = \{v_1, \ldots, v_n\}$. Column $j$ of $[T + U]_\beta^\gamma$ is

$$[(T + U)(v_j)]_\gamma = [T(v_j) + U(v_j)]_\gamma = [T(v_j)]_\gamma + [U(v_j)]_\gamma,$$

using that coordinates respect sums (Bases & Dimension). That is column $j$ of $[T]_\beta^\gamma$ plus column $j$ of $[U]_\beta^\gamma$. Every column agrees, so the matrices agree. The scalar multiple is the same argument with $[aT(v_j)]_\gamma = a[T(v_j)]_\gamma$. $\blacksquare$

Why it's true (picture)

This is a visual argument, not a formal proof. Column $j$ of $[T + U]$ is where $T + U$ sends $e_j$, which is the far corner of the parallelogram on $T(e_j)$ and $U(e_j)$: column $j$ of $[T]$ plus column $j$ of $[U]$. That happens in every column, so it happens to the whole matrix.

The full proof is in the n version.

That gives two routes to the same matrix: combine the formulas first, or combine the matrices.

With the same $T$ and $U$ as before, find $[2T - U]$ two ways.


Directly. $(2T - U)(a_1, a_2) = (2a_1 + 6a_2 - a_2, \ -2a_1 - 2a_1 + a_2) = (2a_1 + 5a_2, \ -4a_1 + a_2)$, so reading down the coefficients,

$$[2T - U] = \begin{pmatrix} 2 & 5 \\ -4 & 1 \end{pmatrix}.$$

With the theorem.

$$2\begin{pmatrix} 1 & 3 \\ -1 & 0 \end{pmatrix} - \begin{pmatrix} 0 & 1 \\ 2 & -1 \end{pmatrix} = \begin{pmatrix} 2 & 5 \\ -4 & 1 \end{pmatrix}.$$

Same answer, as promised.

Step back for a moment. The linear maps from $\V$ to $\W$ are closed under adding and scaling, and with the zero transformation $T_0$ as the zero vector they pass the other vector space rules too. That makes them a vector space of their own.

Let $\V$ and $\W$ be vector spaces. The space of linear maps $\Lin(\V, \W)$ is the vector space of all linear transformations from $\V$ to $\W$, with the sum and scalar multiple above. When $\V = \W$, we write $\Lin(\V)$ instead of $\Lin(\V, \V)$.

It sounds abstract, but for maps $\R^n \to \R^m$ it's familiar ground: by the last theorem, they add and scale exactly like their $m \times n$ matrices.

So linear maps are vectors now. Vectors in a space of maps between spaces of vectors. I need to lie down.

Your turn. Type the matrix row by row.

Loading practice engine...

Adding maps matches adding matrices. The next page asks the bigger question: what does doing one map after another do to their matrices? The answer is the product of matrices, and it explains why that product is defined the strange way it is.

Application: Turning Space

The standard matrix is how a computer stores a motion: three columns, nine numbers, and every point of a 3D scene moves by one matrix-vector product.

The plane's rotation by $\theta$ has matrix $R_\theta$, found by asking where $e_1$ and $e_2$ land on the unit circle. Space works the same way, one more column.

Let $T\colon \R^3 \to \R^3$ turn space about the $z$-axis by the angle $\theta$, counterclockwise as seen from above. Find $[T]$, and find where a quarter turn sends $(1, 2, 3)$.


The $z$-axis doesn't move, so $T(e_3) = e_3$. The floor (the $xy$-plane) turns like the plane does, so $e_1$ and $e_2$ go where $R_\theta$ sends them, with a $0$ height:

$$T(e_1) = (\cos\theta, \sin\theta, 0), \quad T(e_2) = (-\sin\theta, \cos\theta, 0), \quad T(e_3) = (0, 0, 1).$$ $$[T] = \begin{pmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix}.$$

For a quarter turn, $\theta = 90^\circ$, so $\cos\theta = 0$ and $\sin\theta = 1$:

$$\begin{pmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{pmatrix}\begin{pmatrix} 1 \\ 2 \\ 3 \end{pmatrix} = \begin{pmatrix} -2 \\ 1 \\ 3 \end{pmatrix}.$$

The point keeps its height $3$ and swings a quarter turn around the axis.

Turning about the $x$- or $y$-axis is the same idea with a different axis held still: put the fixed axis's column where it was, and a $2 \times 2$ rotation in the other two rows and columns. Game engines and animation software keep motions like these as matrices, and a later page on computer graphics builds on them.

The toolkit for this page: the standard matrix has $T(e_j)$ as column $j$, so read a formula down, and turn the images of another basis into $T(e_j)$ first. In other bases, column $j$ of $[T]_\beta^\gamma$ is $[T(v_j)]_\gamma$, and the matrix turns $[x]_\beta$ into $[T(x)]_\gamma$. Sums and multiples of maps give sums and multiples of matrices.

Mixed Practice

Every question so far came right after its idea, which is a hint a quiz never gives you. Down here the hint is gone. First, true or false: a claim from anywhere on this page, and you decide whether it holds.

Loading practice engine...

Next, a mixed set: every question type on this page, shuffled. The answers are matrices, so this set is multiple choice.

Loading practice engine...

Made it this far? Time for something with a little heat. This time you're handed the matrix and asked about the map. Remember what a column of $[T]_\beta$ actually is. In free response, type the vector's entries, like 3, 4.

🌶️ SPICY BONUS 🌶️

Loading practice engine...