Math Core

Lesson 2.5 · Matrix Algebra

The matrix of a linear transformation

Every matrix gives a linear transformation. This lesson shows the converse: every linear transformation from Rn\mathbb{R}^n to Rm\mathbb{R}^m is multiplication by some matrix, and you can write that matrix down just by watching what the transformation does to nn special vectors. That turns geometric descriptions like "rotate by 30∘30^\circ" or "reflect across a line" into concrete matrices you can compute with.

The standard matrix

The columns of the n×nn \times n identity matrix are the standard basis vectors e1,…,en\mathbf{e}_1, \dots, \mathbf{e}_n of Rn\mathbb{R}^n. In R2\mathbb{R}^2, e1=(1,0)\mathbf{e}_1 = (1, 0) and e2=(0,1)\mathbf{e}_2 = (0, 1). Every vector is a combination of them:

x=[x1⋮xn]=x1e1+⋯+xnen.\mathbf{x} = \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix} = x_1\mathbf{e}_1 + \cdots + x_n\mathbf{e}_n.

If TT is linear, superposition gives

T(x)=x1T(e1)+⋯+xnT(en)=[T(e1)⋯T(en)]x.T(\mathbf{x}) = x_1T(\mathbf{e}_1) + \cdots + x_nT(\mathbf{e}_n) = \begin{bmatrix} T(\mathbf{e}_1) & \cdots & T(\mathbf{e}_n) \end{bmatrix}\mathbf{x}.

The standard matrix of a linear transformation

Let T:Rn→RmT: \mathbb{R}^n \to \mathbb{R}^m be linear. Then there is exactly one m×nm \times n matrix AA with T(x)=AxT(\mathbf{x}) = A\mathbf{x} for every x\mathbf{x} in Rn\mathbb{R}^n, namely

A=[T(e1)T(e2)⋯T(en)].A = \begin{bmatrix} T(\mathbf{e}_1) & T(\mathbf{e}_2) & \cdots & T(\mathbf{e}_n) \end{bmatrix}.

AA is called the standard matrix of TT. Its jjth column is the image of the jjth standard basis vector.

A linear transformation is completely determined by what it does to e1,…,en\mathbf{e}_1, \dots, \mathbf{e}_n. Find those nn images, stack them as columns, and you have the whole transformation.

Worked example: From a formula

Find the standard matrix of T(x1,x2)=(x1−2x2,  3x1,  x1+x2)T(x_1, x_2) = (x_1 - 2x_2, \; 3x_1, \; x_1 + x_2).

TT maps R2\mathbb{R}^2 to R3\mathbb{R}^3, so its matrix is 3×23 \times 2. Compute the images of e1\mathbf{e}_1 and e2\mathbf{e}_2:

T(e1)=T(1,0)=(1,3,1),T(e2)=T(0,1)=(−2,0,1).T(\mathbf{e}_1) = T(1, 0) = (1, 3, 1), \qquad T(\mathbf{e}_2) = T(0, 1) = (-2, 0, 1).

So

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

You can also read AA straight off the formula: row ii of AA holds the coefficients of x1,x2x_1, x_2 in the iith output.

Geometric transformations of the plane

For maps of R2\mathbb{R}^2, find where e1\mathbf{e}_1 and e2\mathbf{e}_2 land, and you're done.

Rotation. Rotating counterclockwise by an angle φ\varphi sends e1\mathbf{e}_1 to (cos⁡φ,sin⁡φ)(\cos\varphi, \sin\varphi) and sends e2\mathbf{e}_2, which starts a quarter turn ahead, to (−sin⁡φ,cos⁡φ)(-\sin\varphi, \cos\varphi). So

rotation by φ:[cos⁡φ−sin⁡φsin⁡φcos⁡φ].\text{rotation by } \varphi: \quad \begin{bmatrix} \cos\varphi & -\sin\varphi \\ \sin\varphi & \cos\varphi \end{bmatrix}.

The same reasoning gives the whole table below. In each case the columns are the images of e1\mathbf{e}_1 and e2\mathbf{e}_2.

TransformationImage of e1\mathbf{e}_1Image of e2\mathbf{e}_2Standard matrix
Reflection across the x1x_1-axis(1,0)(1, 0)(0,−1)(0, -1)[100−1]\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}
Reflection across the x2x_2-axis(−1,0)(-1, 0)(0,1)(0, 1)[−1001]\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}
Reflection across x2=x1x_2 = x_1(0,1)(0, 1)(1,0)(1, 0)[0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}
Reflection across x2=−x1x_2 = -x_1(0,−1)(0, -1)(−1,0)(-1, 0)[0−1−10]\begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}
Reflection through the origin(−1,0)(-1, 0)(0,−1)(0, -1)[−100−1]\begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}
Horizontal shear by kk(1,0)(1, 0)(k,1)(k, 1)[1k01]\begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix}
Vertical shear by kk(1,k)(1, k)(0,1)(0, 1)[10k1]\begin{bmatrix} 1 & 0 \\ k & 1 \end{bmatrix}
Horizontal stretch by kk(k,0)(k, 0)(0,1)(0, 1)[k001]\begin{bmatrix} k & 0 \\ 0 & 1 \end{bmatrix}
Projection onto the x1x_1-axis(1,0)(1, 0)(0,0)(0, 0)[1000]\begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}

Don't memorize the table. Rebuild any row in seconds by asking where e1\mathbf{e}_1 and e2\mathbf{e}_2 go.

Worked example: A quarter turn

Find the standard matrix of the counterclockwise rotation by 90∘90^\circ, and describe the image of the unit square.

With φ=90∘\varphi = 90^\circ, cos⁡φ=0\cos\varphi = 0 and sin⁡φ=1\sin\varphi = 1, so

A=[0−110],A[x1x2]=[−x2x1].A = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}, \qquad A\begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} -x_2 \\ x_1 \end{bmatrix}.

The corners (0,0)(0,0), (1,0)(1,0), (1,1)(1,1), (0,1)(0,1) go to (0,0)(0,0), (0,1)(0,1), (−1,1)(-1,1), (−1,0)(-1,0): the square swings into the second quadrant.

The unit square in the first quadrant and its image after a 90° counterclockwise rotation, in the second quadrant.Open in grapher →

Composition is multiplication

If you apply TT with standard matrix AA and then SS with standard matrix BB, the combined map sends x\mathbf{x} to B(Ax)=(BA)xB(A\mathbf{x}) = (BA)\mathbf{x}. So the standard matrix of "first TT, then SS" is BABA: the matrix of the first step goes on the right. This is exactly why matrix multiplication was defined as it was.

Worked example: Reflect, then shear

T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 first reflects across the line x2=x1x_2 = x_1 and then applies the horizontal shear [1201]\begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}. Find the standard matrix of TT.

The reflection has matrix R=[0110]R = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} and is applied first, so

A=[1201][0110]=[2110].A = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 1 & 0 \end{bmatrix}.

Check with e1\mathbf{e}_1: the reflection sends it to e2=(0,1)\mathbf{e}_2 = (0,1), and the shear sends (0,1)(0, 1) to (2,1)(2, 1), which is the first column of AA.

The unit square and its image under T, the parallelogram with corners (0,0), (2,1), (3,1), (1,0).Open in grapher →

Common mistake

Order matters. "First AA, then BB" is the product BABA, not ABAB. In the example above, doing the shear first and the reflection second gives [0112]\begin{bmatrix} 0 & 1 \\ 1 & 2 \end{bmatrix}, a different transformation.

One-to-one and onto

Definition

Onto and one-to-one

A mapping T:Rn→RmT: \mathbb{R}^n \to \mathbb{R}^m is onto Rm\mathbb{R}^m if every b\mathbf{b} in Rm\mathbb{R}^m is the image of at least one x\mathbf{x} in Rn\mathbb{R}^n. It is one-to-one if every b\mathbf{b} in Rm\mathbb{R}^m is the image of at most one x\mathbf{x}.

Onto is an existence question (is Ax=bA\mathbf{x} = \mathbf{b} always consistent?), and one-to-one is a uniqueness question (can Ax=bA\mathbf{x} = \mathbf{b} ever have two solutions?). Translating with what you already know about Ax=bA\mathbf{x} = \mathbf{b}:

  • TT is onto Rm\mathbb{R}^m   ⟺  \iff the columns of AA span Rm\mathbb{R}^m   ⟺  \iff AA has a pivot in every row.
  • TT is one-to-one   ⟺  \iff T(x)=0T(\mathbf{x}) = \mathbf{0} has only the trivial solution   ⟺  \iff the columns of AA are linearly independent   ⟺  \iff AA has a pivot in every column.

The middle criterion for one-to-one uses linearity: if T(u)=T(v)T(\mathbf{u}) = T(\mathbf{v}) with u≠v\mathbf{u} \ne \mathbf{v}, then T(u−v)=0T(\mathbf{u} - \mathbf{v}) = \mathbf{0} with u−v≠0\mathbf{u} - \mathbf{v} \ne \mathbf{0}.

Counting pivots gives quick size limits. A map Rn→Rm\mathbb{R}^n \to \mathbb{R}^m with n>mn > m can't be one-to-one (too many columns for each to get a pivot), and one with n<mn < m can't be onto. For n=mn = m, the Invertible Matrix Theorem says one-to-one and onto happen together, exactly when AA is invertible.

Worked example: Checking both properties

Let T(x1,x2,x3)=(x1−x2+2x3,  2x1+x2−x3)T(x_1, x_2, x_3) = (x_1 - x_2 + 2x_3, \; 2x_1 + x_2 - x_3). Is TT one-to-one? Is it onto R2\mathbb{R}^2?

The standard matrix and its echelon form are

A=[1−1221−1]∼[1−1203−5].A = \begin{bmatrix} 1 & -1 & 2 \\ 2 & 1 & -1 \end{bmatrix} \sim \begin{bmatrix} 1 & -1 & 2 \\ 0 & 3 & -5 \end{bmatrix}.

There is a pivot in both rows, so TT is onto R2\mathbb{R}^2. Column 3 has no pivot, so x3x_3 is free, T(x)=0T(\mathbf{x}) = \mathbf{0} has nontrivial solutions, and TT is not one-to-one.

Tip

To check a standard matrix you built, test it on one vector that is not e1\mathbf{e}_1 or e2\mathbf{e}_2. For example, a rotation by 90∘90^\circ should send (1,1)(1, 1) to (−1,1)(-1, 1), and indeed [0−110][11]=[−11]\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} -1 \\ 1 \end{bmatrix}.

Practice

Practice 1

Let T(x1,x2)=(2x1+x2,  x1−3x2,  −x2)T(x_1, x_2) = (2x_1 + x_2, \; x_1 - 3x_2, \; -x_2). What is the second column of the standard matrix of TT? Enter it as (a,b,c)(a, b, c).

Enter a point like (2, -3)

Practice 2

T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 is linear with T(e1)=(1,2)T(\mathbf{e}_1) = (1, 2) and T(e2)=(−1,4)T(\mathbf{e}_2) = (-1, 4). Find T(3,−2)T(3, -2).

Enter a point like (2, -3)

Practice 3

Find the image of (2,0)(2, 0) under the counterclockwise rotation of R2\mathbb{R}^2 by 60∘60^\circ. Enter exact values; you may type sqrt(3).

Enter a point like (2, -3)

Practice 4

Find the image of (3,1)(3, 1) under reflection across the line x2=−x1x_2 = -x_1.

Enter a point like (2, -3)

Practice 5

TT first rotates R2\mathbb{R}^2 counterclockwise by 90∘90^\circ and then reflects across the x1x_1-axis. Which single transformation is TT?

Practice 6

Let T(x)=AxT(\mathbf{x}) = A\mathbf{x} with A=[12013−1]A = \begin{bmatrix} 1 & 2 \\ 0 & 1 \\ 3 & -1 \end{bmatrix}. Which statement is true?

Practice 7

T:R5→R3T: \mathbb{R}^5 \to \mathbb{R}^3 is linear, and its standard matrix has 33 pivot positions. Which statement is true?

Practice 8

A horizontal shear [1k01]\begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix} sends the point (1,2)(1, 2) to (7,2)(7, 2). Find kk.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.