Dove's LibraryDove's Library

4.13 - Matrices as Functions

Overview

In Topic 4.12 you saw that every linear transformation of the plane is multiplication by a 2×22 \times 2 matrix. This topic treats the matrix as a function and asks the questions you'd ask about any function. How do you build the matrix from a description like "rotate 60∘60^\circ"? What does it do to areas? What happens when you compose two transformations, and how do you undo one?

The matrix behind a transformation

Write aija_{ij} for the entry in row ii and column jj. Then the linear transformation
L(⟨x,y⟩)=⟨a11x+a12y,  a21x+a22y⟩L(\langle x, y \rangle) = \langle a_{11}x + a_{12}y, \; a_{21}x + a_{22}y \rangle
is associated with the matrix
A=[a11a12a21a22]A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}
Row ii of AA builds the iith component of the output. Column 1 holds the coefficients of xx, and column 2 holds the coefficients of yy.

The unit vectors give you the columns

The fastest way to find the matrix of a transformation is to ask where the unit vectors i⃗=⟨1,0⟩\vec{i} = \langle 1, 0 \rangle and j⃗=⟨0,1⟩\vec{j} = \langle 0, 1 \rangle go. Multiply each one by AA:
Ai⃗=[a11a12a21a22][10]=[a11a21]Aj⃗=[a11a12a21a22][01]=[a12a22]A\vec{i} = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} a_{11} \\ a_{21} \end{bmatrix} \qquad A\vec{j} = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}\begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} a_{12} \\ a_{22} \end{bmatrix}
The first column of AA is the image of i⃗\vec{i}, and the second column is the image of j⃗\vec{j}. So to build a matrix, figure out where i⃗\vec{i} and j⃗\vec{j} land and write those two vectors as the columns.
Why is that enough to know where every vector goes? Any vector can be built from the unit vectors, ⟨x,y⟩=xi⃗+yj⃗\langle x, y \rangle = x\vec{i} + y\vec{j}, and multiplying by AA keeps that recipe:
A[xy]=x[a11a21]+y[a12a22]=x(Ai⃗)+y(Aj⃗)A\begin{bmatrix} x \\ y \end{bmatrix} = x\begin{bmatrix} a_{11} \\ a_{21} \end{bmatrix} + y\begin{bmatrix} a_{12} \\ a_{22} \end{bmatrix} = x(A\vec{i}) + y(A\vec{j})
In pictures, the unit square (with sides i⃗\vec{i} and j⃗\vec{j}) is sent to the parallelogram with sides Ai⃗A\vec{i} and Aj⃗A\vec{j}. Here's that picture for the matrix in Example 1.
4.13 - Matrices as Functions

Example 1: A matrix from the images of i⃗\vec{i} and j⃗\vec{j}

A linear transformation LL sends i⃗\vec{i} to ⟨2,1⟩\langle 2, 1 \rangle and j⃗\vec{j} to ⟨−1,3⟩\langle -1, 3 \rangle. Find the matrix of LL, and use it to find L(⟨4,−2⟩)L(\langle 4, -2 \rangle).
The images of i⃗\vec{i} and j⃗\vec{j} are the columns:
A=[2−113]A = \begin{bmatrix} 2 & -1 \\ 1 & 3 \end{bmatrix}
Then
L(⟨4,−2⟩)=[2−113][4−2]=[8+24−6]=[10−2]L(\langle 4, -2 \rangle) = \begin{bmatrix} 2 & -1 \\ 1 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ -2 \end{bmatrix} = \begin{bmatrix} 8 + 2 \\ 4 - 6 \end{bmatrix} = \begin{bmatrix} 10 \\ -2 \end{bmatrix}
Check with the unit vector recipe: 4⟨2,1⟩−2⟨−1,3⟩=⟨8+2,  4−6⟩=⟨10,−2⟩4\langle 2, 1 \rangle - 2\langle -1, 3 \rangle = \langle 8 + 2, \; 4 - 6 \rangle = \langle 10, -2 \rangle. Answer: L(⟨4,−2⟩)=⟨10,−2⟩L(\langle 4, -2 \rangle) = \langle 10, -2 \rangle.

Example 2: Reflecting over y=xy = x

Find the matrix that reflects every vector over the line y=xy = x.
Reflecting over y=xy = x swaps the coordinates of a point. So i⃗=⟨1,0⟩\vec{i} = \langle 1, 0 \rangle lands on ⟨0,1⟩\langle 0, 1 \rangle, and j⃗=⟨0,1⟩\vec{j} = \langle 0, 1 \rangle lands on ⟨1,0⟩\langle 1, 0 \rangle. Those are the columns:
A=[0110]Check: [0110][xy]=[yx]A = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \qquad \text{Check: } \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} y \\ x \end{bmatrix}
The same method gives the matrices for the common transformations:
Transformation
i⃗\vec{i} goes to
j⃗\vec{j} goes to
Matrix
Reflect over the xx-axis
⟨1,0⟩\langle 1, 0 \rangle
⟨0,−1⟩\langle 0, -1 \rangle
[100−1]\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}
Reflect over the yy-axis
⟨−1,0⟩\langle -1, 0 \rangle
⟨0,1⟩\langle 0, 1 \rangle
[−1001]\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}
Reflect over y=xy = x
⟨0,1⟩\langle 0, 1 \rangle
⟨1,0⟩\langle 1, 0 \rangle
[0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}
Reflect over y=−xy = -x
⟨0,−1⟩\langle 0, -1 \rangle
⟨−1,0⟩\langle -1, 0 \rangle
[0−1−10]\begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}
Rotate 90∘90^\circ counterclockwise
⟨0,1⟩\langle 0, 1 \rangle
⟨−1,0⟩\langle -1, 0 \rangle
[0−110]\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}
Rotate 180∘180^\circ
⟨−1,0⟩\langle -1, 0 \rangle
⟨0,−1⟩\langle 0, -1 \rangle
[−100−1]\begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}
Dilate by a factor of kk
⟨k,0⟩\langle k, 0 \rangle
⟨0,k⟩\langle 0, k \rangle
[k00k]\begin{bmatrix} k & 0 \\ 0 & k \end{bmatrix}
Stretch horizontally by a factor of kk
⟨k,0⟩\langle k, 0 \rangle
⟨0,1⟩\langle 0, 1 \rangle
[k001]\begin{bmatrix} k & 0 \\ 0 & 1 \end{bmatrix}

Rotation matrices

The matrix that rotates every vector by an angle θ\theta counterclockwise about the origin is
Rθ=[cos⁡θ−sin⁡θsin⁡θcos⁡θ]R_\theta = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}
You can build it with the unit vector method and the unit circle. The vector i⃗\vec{i} points at angle 0 on the unit circle. Rotating it by θ\theta lands it at angle θ\theta, which is the point ⟨cos⁡θ,sin⁡θ⟩\langle \cos\theta, \sin\theta \rangle. That's column 1. The vector j⃗\vec{j} points at angle 90∘90^\circ, so it lands at angle θ+90∘\theta + 90^\circ:
⟨cos⁡(θ+90∘),  sin⁡(θ+90∘)⟩=⟨−sin⁡θ,  cos⁡θ⟩\langle \cos(\theta + 90^\circ), \; \sin(\theta + 90^\circ) \rangle = \langle -\sin\theta, \; \cos\theta \rangle
That's column 2.
4.13 - Matrices as Functions
A few things to remember:
  • Clockwise rotations use −θ-\theta. Since cos⁡(−θ)=cos⁡θ\cos(-\theta) = \cos\theta and sin⁡(−θ)=−sin⁡θ\sin(-\theta) = -\sin\theta, the clockwise matrix is [cos⁡θsin⁡θ−sin⁡θcos⁡θ]\begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix}.
  • Rotations keep lengths. A rotated vector has the same magnitude as the original.
  • Check with θ=90∘\theta = 90^\circ. You should get [0−110]\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}, which matches the table above.

Example 3: Rotating a vector

Rotate the vector ⟨4,2⟩\langle 4, 2 \rangle by 60∘60^\circ counterclockwise about the origin.
Use cos⁡60∘=12\cos 60^\circ = \frac{1}{2} and sin⁡60∘=32\sin 60^\circ = \frac{\sqrt{3}}{2}:
R60∘[42]=[12−323212][42]=[2−323+1]≈[0.2684.464]R_{60^\circ}\begin{bmatrix} 4 \\ 2 \end{bmatrix} = \begin{bmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{bmatrix}\begin{bmatrix} 4 \\ 2 \end{bmatrix} = \begin{bmatrix} 2 - \sqrt{3} \\ 2\sqrt{3} + 1 \end{bmatrix} \approx \begin{bmatrix} 0.268 \\ 4.464 \end{bmatrix}
Check: the length shouldn't change. The original has length 42+22=20\sqrt{4^2 + 2^2} = \sqrt{20}. For the image,
(2−3)2+(23+1)2=(7−43)+(13+43)=20(2 - \sqrt{3})^2 + (2\sqrt{3} + 1)^2 = (7 - 4\sqrt{3}) + (13 + 4\sqrt{3}) = 20
so its length is also 20\sqrt{20}. Answer: ⟨2−3,  23+1⟩≈⟨0.268,4.464⟩\langle 2 - \sqrt{3}, \; 2\sqrt{3} + 1 \rangle \approx \langle 0.268, 4.464 \rangle.

The determinant measures how area changes

In Topic 4.11, ∣det⁡(A)∣|\det(A)| was the area of the parallelogram spanned by the columns of AA. Now you know those columns are Ai⃗A\vec{i} and Aj⃗A\vec{j}, the images of the unit square's sides. So the unit square, with area 1, becomes a parallelogram with area ∣det⁡(A)∣|\det(A)|. In the unit square figure above, det⁡(A)=(2)(3)−(−1)(1)=7\det(A) = (2)(3) - (-1)(1) = 7, and the image of the unit square has area 7.
The same scale factor applies to every region, because any shape can be filled with tiny squares and each one gets scaled by the same amount. So the absolute value of the determinant is the dilation factor for area:
area of image=∣det⁡(A)∣×area of original\text{area of image} = |\det(A)| \times \text{area of original}
  • ∣det⁡(A)∣>1|\det(A)| > 1: areas get bigger.
  • ∣det⁡(A)∣<1|\det(A)| < 1: areas shrink.
  • ∣det⁡(A)∣=1|\det(A)| = 1: areas stay the same. Rotations (det⁡=cos⁡2θ+sin⁡2θ=1\det = \cos^2\theta + \sin^2\theta = 1) and reflections (det⁡=−1\det = -1) are like this.
  • det⁡(A)=0\det(A) = 0: the whole plane gets squashed onto a line (or a single point), and every region ends up with area 0.
A negative determinant means the transformation also flips the plane over, the way a reflection does. For area, only the absolute value matters.

Example 4: The area of an image

The triangle with vertices P(1,1)P(1, 1), Q(3,1)Q(3, 1), and R(2,3)R(2, 3) is transformed by A=[−2111]A = \begin{bmatrix} -2 & 1 \\ 1 & 1 \end{bmatrix} (the transformation from Topic 4.12, Example 3). Find the area of the image triangle.
The original triangle has base PQ=2PQ = 2 and height 2 (from y=1y = 1 up to y=3y = 3), so its area is 12(2)(2)=2\frac{1}{2}(2)(2) = 2. The determinant is
det⁡(A)=(−2)(1)−(1)(1)=−3\det(A) = (-2)(1) - (1)(1) = -3
so areas get multiplied by ∣−3∣=3|-3| = 3. Answer: the image triangle has area 3×2=63 \times 2 = 6 square units.
Check: the image vertices are P′(−1,2)P'(-1, 2), Q′(−5,4)Q'(-5, 4), and R′(−1,5)R'(-1, 5). Side P′R′P'R' is vertical with length 3, and Q′Q' sits 4 units to its left, so the area is 12(3)(4)=6\frac{1}{2}(3)(4) = 6.

Composing linear transformations

Say L1(v⃗)=Av⃗L_1(\vec{v}) = A\vec{v} and L2(v⃗)=Bv⃗L_2(\vec{v}) = B\vec{v}. Doing L1L_1 first and then L2L_2 is the composition L2∘L1L_2 \circ L_1:
(L2∘L1)(v⃗)=L2(L1(v⃗))=B(Av⃗)=(BA)v⃗(L_2 \circ L_1)(\vec{v}) = L_2(L_1(\vec{v})) = B(A\vec{v}) = (BA)\vec{v}
Two facts come out of this:
  • The composition of two linear transformations is a linear transformation. It's multiplication by the 2×22 \times 2 matrix BABA, and every 2×22 \times 2 matrix gives a linear transformation.
  • The matrix of the composition is the product of the two matrices, with the transformation that happens first on the right, next to v⃗\vec{v}. It's just like f(g(x))f(g(x)), where gg happens first even though it's written second.
Since BABA and ABAB are usually different matrices, the order of the transformations matters.
Rotations are a good check on this rule. Rotating by α\alpha and then by β\beta should be the same as rotating by α+β\alpha + \beta. Multiply RβRαR_\beta R_\alpha, and the top left entry is cos⁡βcos⁡α−sin⁡βsin⁡α\cos\beta\cos\alpha - \sin\beta\sin\alpha, which is cos⁡(α+β)\cos(\alpha + \beta) by the angle sum identity from Unit 3. The other entries work out the same way, so RβRα=Rα+βR_\beta R_\alpha = R_{\alpha + \beta}.

Example 5: Order matters

Let RR rotate vectors 90∘90^\circ counterclockwise, and let FF reflect vectors over the xx-axis:
R=[0−110]F=[100−1]R = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \qquad F = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}
Find the matrix for (a) rotating and then reflecting, and (b) reflecting and then rotating. Describe each one.
(a) The rotation happens first, so RR goes on the right:
FR=[100−1][0−110]=[0−1−10]FR = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}
This sends ⟨x,y⟩\langle x, y \rangle to ⟨−y,−x⟩\langle -y, -x \rangle, a reflection over the line y=−xy = -x.
(b) Now the reflection happens first, so FF goes on the right:
RF=[0−110][100−1]=[0110]RF = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}
This sends ⟨x,y⟩\langle x, y \rangle to ⟨y,x⟩\langle y, x \rangle, a reflection over the line y=xy = x.
Test both with ⟨2,1⟩\langle 2, 1 \rangle. Rotating gives ⟨−1,2⟩\langle -1, 2 \rangle, and then reflecting gives ⟨−1,−2⟩\langle -1, -2 \rangle, which is what FRFR gives. Reflecting first gives ⟨2,−1⟩\langle 2, -1 \rangle, and then rotating gives ⟨1,2⟩\langle 1, 2 \rangle, which is what RFRF gives. Same two steps, different order, different result. The figure follows a triangle through both orders (the dot marks the vertex that starts at (2,1)(2, 1), and the dashed triangle shows the result of the first step).
4.13 - Matrices as Functions

Inverse transformations

Two linear transformations are inverses if composing them, in either order, maps every vector back to itself:
L−1(L(v⃗))=v⃗andL(L−1(v⃗))=v⃗L^{-1}(L(\vec{v})) = \vec{v} \quad \text{and} \quad L(L^{-1}(\vec{v})) = \vec{v}
If L(v⃗)=Av⃗L(\vec{v}) = A\vec{v}, the inverse transformation uses the inverse matrix:
L−1(v⃗)=A−1v⃗L^{-1}(\vec{v}) = A^{-1}\vec{v}
This works because the composition has matrix A−1A=IA^{-1}A = I, and Iv⃗=v⃗I\vec{v} = \vec{v} for every vector.
So LL has an inverse exactly when det⁡(A)≠0\det(A) \neq 0. The picture explains why. When det⁡(A)=0\det(A) = 0, the plane gets squashed onto a line, and many different inputs land on the same output. There's no way to undo that, because you couldn't tell which input an output came from.
Two inverses you can find without any algebra:
  • The inverse of rotating by θ\theta is rotating back by −θ-\theta. The formula agrees: det⁡(Rθ)=1\det(R_\theta) = 1, and the swap-and-negate step turns RθR_\theta into R−θR_{-\theta}.
  • A reflection is its own inverse. Reflect twice over the same line and you're back where you started, so FF=IFF = I.

Example 6: Undoing and composing

Let L(v⃗)=Av⃗L(\vec{v}) = A\vec{v}, where A=[3152]A = \begin{bmatrix} 3 & 1 \\ 5 & 2 \end{bmatrix}.
  • (a) Explain why LL has an inverse, and find a formula for L−1L^{-1}.
  • (b) A vector v⃗\vec{v} satisfies L(v⃗)=⟨4,7⟩L(\vec{v}) = \langle 4, 7 \rangle. Find v⃗\vec{v}.
  • (c) Let MM be the transformation that applies LL and then rotates 90∘90^\circ counterclockwise. Find the matrix of MM and use it to find M(⟨1,1⟩)M(\langle 1, 1 \rangle).
(a) det⁡(A)=(3)(2)−(1)(5)=1\det(A) = (3)(2) - (1)(5) = 1. That isn't 0, so LL has an inverse. Swap, change signs, and divide by 1:
A−1=[2−1−53]L−1(⟨x,y⟩)=⟨2x−y,  −5x+3y⟩A^{-1} = \begin{bmatrix} 2 & -1 \\ -5 & 3 \end{bmatrix} \qquad L^{-1}(\langle x, y \rangle) = \langle 2x - y, \; -5x + 3y \rangle
(b) Undo LL by applying L−1L^{-1} to the output:
v⃗=A−1[47]=[2−1−53][47]=[8−7−20+21]=[11]\vec{v} = A^{-1}\begin{bmatrix} 4 \\ 7 \end{bmatrix} = \begin{bmatrix} 2 & -1 \\ -5 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ 7 \end{bmatrix} = \begin{bmatrix} 8 - 7 \\ -20 + 21 \end{bmatrix} = \begin{bmatrix} 1 \\ 1 \end{bmatrix}
Check: A[11]=[3+15+2]=[47]A\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 3 + 1 \\ 5 + 2 \end{bmatrix} = \begin{bmatrix} 4 \\ 7 \end{bmatrix}. So v⃗=⟨1,1⟩\vec{v} = \langle 1, 1 \rangle.
(c) LL happens first, so AA goes on the right, with the 90∘90^\circ rotation matrix on the left:
[0−110][3152]=[−5−231]\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 3 & 1 \\ 5 & 2 \end{bmatrix} = \begin{bmatrix} -5 & -2 \\ 3 & 1 \end{bmatrix}M(⟨1,1⟩)=[−5−231][11]=[−74]M(\langle 1, 1 \rangle) = \begin{bmatrix} -5 & -2 \\ 3 & 1 \end{bmatrix}\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} -7 \\ 4 \end{bmatrix}
This matches doing it in two steps: L(⟨1,1⟩)=⟨4,7⟩L(\langle 1, 1 \rangle) = \langle 4, 7 \rangle from part (b), and rotating ⟨4,7⟩\langle 4, 7 \rangle by 90∘90^\circ gives ⟨−7,4⟩\langle -7, 4 \rangle. Answer: M(⟨1,1⟩)=⟨−7,4⟩M(\langle 1, 1 \rangle) = \langle -7, 4 \rangle.

Common mistakes

  • Writing the images of i⃗\vec{i} and j⃗\vec{j} as rows. They go in as columns.
  • Composing in the wrong order. If AA happens first and then BB, the matrix is BABA. The first transformation sits on the right.
  • Mixing up the rotation matrix. For a counterclockwise rotation, −sin⁡θ-\sin\theta goes in the top right. Putting it in the bottom left rotates the other way.
  • Using the wrong calculator mode. If θ\theta is in degrees, the calculator has to be in degree mode.
  • Forgetting the absolute value, or forgetting to multiply by the original area, when you use the determinant to find an image's area.
  • Inverting a transformation with determinant 0. It squashes the plane, so it can't be undone.

AP® is a registered trademark of the College Board, which is not affiliated with Dove's Library and was not involved in the production of, and does not endorse, this website.

Providing free, high-quality AP notes to help students succeed, earn college credit, and reach their educational goals, ensuring everyone has access to the resources they need.

© 2026 Standard Learning Group, Inc., which operates Dove's Library. All rights reserved.