Linear AlgebraLinear Transformations4 of 7
Linear Transformations · 4

Composing Maps Is Multiplying Matrices

We know how to describe a single linear map with a matrix, and now we want to find the single matrix for two linear maps done one right after the other.

1

Why Composing Maps Is Multiplying Matrices

When we apply a first linear map SS to a vector x\thevector{x} and then plug that result straight into a second linear map TT, we get a single combined map:

T(S(x))\displaystyle T(S(\thevector{x})) =(T∘S)⏟composition(x)\displaystyle = \underbrace{(T \circ S)}_{\text{composition}}(\thevector{x})

The circle reads "TT after SS": because SS sits right next to x\thevector{x}, SS happens first and TT happens second. Since both maps keep grid lines parallel and evenly spaced and keep the origin fixed at (0,0)(0, 0), the combined map T∘ST \circ S is also a linear map with its own matrix.

Why Composing Maps Is Multiplying Matrices
==

Let's find the matrix for T∘ST \circ S when SS has matrix [2−112]\begin{bmatrix} \firstcol{2} & \secondcol{-1} \\ \firstcol{1} & \secondcol{2} \end{bmatrix} and TT has matrix [1320]\begin{bmatrix} \acting{1} & \acting{3} \\ \acting{2} & \acting{0} \end{bmatrix}.

Text solution
Follow the first basis vector (1,0)\firstcol{(1, 0)} through SS and then TTThe first map SS sends (1,0)\firstcol{(1, 0)} to its first column (2,1)\firstcol{(2, 1)}, and the second map TT sends (2,1)\firstcol{(2, 1)} to the first column of T∘ST \circ S.
T(S(1,0))=[1320][21]=2[12]+1[30]=[54]\displaystyle T(S(\firstcol{1, 0})) = \begin{bmatrix} \acting{1} & \acting{3} \\ \acting{2} & \acting{0} \end{bmatrix}\begin{bmatrix} \firstcol{2} \\ \firstcol{1} \end{bmatrix} = \firstcol{2}\begin{bmatrix} \acting{1} \\ \acting{2} \end{bmatrix} + \firstcol{1}\begin{bmatrix} \acting{3} \\ \acting{0} \end{bmatrix} = \begin{bmatrix} \firstcol{5} \\ \firstcol{4} \end{bmatrix}
Follow the second basis vector (0,1)\secondcol{(0, 1)} through SS and then TTThe first map SS sends (0,1)\secondcol{(0, 1)} to its second column (−1,2)\secondcol{(-1, 2)}, and TT sends (−1,2)\secondcol{(-1, 2)} to the second column of T∘ST \circ S.
T(S(0,1))=[1320][−12]=−1[12]+2[30]=[5−2]\displaystyle T(S(\secondcol{0, 1})) = \begin{bmatrix} \acting{1} & \acting{3} \\ \acting{2} & \acting{0} \end{bmatrix}\begin{bmatrix} \secondcol{-1} \\ \secondcol{2} \end{bmatrix} = \secondcol{-1}\begin{bmatrix} \acting{1} \\ \acting{2} \end{bmatrix} + \secondcol{2}\begin{bmatrix} \acting{3} \\ \acting{0} \end{bmatrix} = \begin{bmatrix} \secondcol{5} \\ \secondcol{-2} \end{bmatrix}
Put both final landing spots into the product matrix TSTSPlacing those two final landing spots side by side gives the matrix for T∘ST \circ S, which is the matrix of TT times the matrix of SS.
Matrix of (T∘S)=[1320]⏟second map T[2−112]⏟first map S=[554−2]\displaystyle \text{Matrix of }(T \circ S) = \underbrace{\begin{bmatrix} \acting{1} & \acting{3} \\ \acting{2} & \acting{0} \end{bmatrix}}_{\text{second map } T}\underbrace{\begin{bmatrix} \firstcol{2} & \secondcol{-1} \\ \firstcol{1} & \secondcol{2} \end{bmatrix}}_{\text{first map } S} = \begin{bmatrix} \firstcol{5} & \secondcol{5} \\ \firstcol{4} & \secondcol{-2} \end{bmatrix}

In the grid below, each column of TSTS is where the second map TT sends the matching column of the first map SS, showing where (1,0)\firstcol{(1, 0)} and (0,1)\secondcol{(0, 1)} land after doing SS and then TT.

Each column of the combined matrix is where the second transformation sends that column of the first matrix, tracking where each starting basis vector lands after both steps.
2

Why Order Matters and Grouping Doesn't

Now that we can find the matrix of a combined map by multiplying, we want to see what happens when we swap the order of two maps, or when we chain three maps in a row.

Why Order Matters and Grouping Doesn't
3×5=5×3AB?BA\begin{aligned} 3 \times 5 &= 5 \times 3 \\[4pt] AB &\mathrel{\htmlClass{lc-mute}{?}} BA \end{aligned}
[21]\htmlClass{lc-blue}{\begin{bmatrix} 2 \\ 1 \end{bmatrix}}

Let's compare combining a reflection FF across the xx-axis and a 90∘90^\circ counterclockwise rotation RR in both orders.

Text solution
Find the matrices for FF and RR from the basis vectorsReflecting across the xx-axis leaves (1,0)\firstcol{(1, 0)} fixed and flips (0,1)\secondcol{(0, 1)} to (0,−1)\secondcol{(0, -1)}, while rotating 90∘90^\circ counterclockwise sends (1,0)\firstcol{(1, 0)} to (0,1)\firstcol{(0, 1)} and (0,1)\secondcol{(0, 1)} to (−1,0)\secondcol{(-1, 0)}.
F=[100−1],R=[0−110]\displaystyle F = \begin{bmatrix} \firstcol{1} & \secondcol{0} \\ \firstcol{0} & \secondcol{-1} \end{bmatrix}, \qquad R = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}
Reflect first, then rotate (R∘FR \circ F)Place the first map FF on the right and apply RR to each column of FF.
RF=[0−110][100−1]=[0110]\displaystyle RF = \begin{bmatrix} \acting{0} & \acting{-1} \\ \acting{1} & \acting{0} \end{bmatrix}\begin{bmatrix} \firstcol{1} & \secondcol{0} \\ \firstcol{0} & \secondcol{-1} \end{bmatrix} = \begin{bmatrix} \firstcol{0} & \secondcol{1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}
Because (1,0)\firstcol{(1, 0)} and (0,1)\secondcol{(0, 1)} swap places, doing FF first and RR second is a single reflection across the line y=xy = x.
Rotate first, then reflect (F∘RF \circ R)Swap the order so RR sits on the right and apply FF to each column of RR.
FR=[100−1][0−110]=[0−1−10]\displaystyle FR = \begin{bmatrix} \acting{1} & \acting{0} \\ \acting{0} & \acting{-1} \end{bmatrix}\begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix} = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{-1} & \secondcol{0} \end{bmatrix}
Sending (1,0)\firstcol{(1, 0)} to (0,−1)\firstcol{(0, -1)} and (0,1)\secondcol{(0, 1)} to (−1,0)\secondcol{(-1, 0)} is a reflection across the opposite diagonal line y=−xy = -x, so RF≠FRRF \neq FR.

On the grid below, reflecting across the xx-axis and then rotating 90∘90^\circ counterclockwise reflects every vector x\thevector{x} across y=xy = x, while rotating first and reflecting second reflects x\thevector{x} across y=−xy = -x.

Reflecting across the horizontal axis and rotating 90 degrees counterclockwise acts as a single reflection across the upward diagonal when you reflect first, and across the downward diagonal when you rotate first.

While changing the order of maps can change the outcome, changing how we group three maps in a fixed order does not:

(AB)C\displaystyle (AB)C =A(BC)\displaystyle = A(BC)
x\htmlClass{lc-blue}{x}
C\htmlClass{lc-violet}{C}
B\htmlClass{lc-violet}{B}
A\htmlClass{lc-violet}{A}
C\htmlClass{lc-violet}{C}
B\htmlClass{lc-violet}{B}
A\htmlClass{lc-violet}{A}
1st\text{1st}
2nd\text{2nd}
3rd\text{3rd}
ABAB
BCBC

Both sides run the exact same sequence of actions (CC first, then BB, then AA), and moving the parentheses only changes which two adjacent steps we combine into a single matrix first.

3

Maps Between Different Dimensions

So far, every map has taken 2D vectors to 2D vectors, giving a 2×22 \times 2 square matrix. Now we want to find the matrix size for a map between spaces of different dimensions, and see when two maps of different sizes can be composed.

Maps Between Different Dimensions
3D\text{3D}
S\htmlClass{lc-violet}{S}
2D\text{2D}
x\htmlClass{lc-mute}{x}
y\htmlClass{lc-mute}{y}
z\htmlClass{lc-mute}{z}

Let's find the matrix sizes for a map SS from 3D space to 2D space followed by a map TT from 2D space to 4D space.

Text solution
Count output coordinates and input basis vectors for each matrixA map needs one column for each starting basis vector in its input space and one row for each coordinate in its output space, making SS a 2×32 \times 3 matrix and TT a 4×24 \times 2 matrix.
Size of S=2⏟2D output×3⏟3D input,Size of T=4⏟4D output×2⏟2D input\displaystyle \begin{aligned} \text{Size of }S &= \underbrace{2}_{\text{2D output}} \times \underbrace{3}_{\text{3D input}}, \\ \text{Size of }T &= \underbrace{4}_{\text{4D output}} \times \underbrace{2}_{\text{2D input}} \end{aligned}
Match the middle space to find the size of TSTSBecause SS outputs 2D vectors and TT takes 2D inputs, the composition T∘ST \circ S makes sense, taking 3D inputs at the start and producing 4D outputs at the end.
(4×2)⏟second map T(2×3)⏟first map S\displaystyle \underbrace{(4 \times 2)}_{\text{second map }T}\quad\underbrace{(2 \times 3)}_{\text{first map }S} =4×3⏟combined map TS\displaystyle = \underbrace{4 \times 3}_{\text{combined map }TS}
3D\text{3D}
2D\text{2D}
4D\text{4D}
S\htmlClass{lc-violet}{S}
T\htmlClass{lc-violet}{T}
(4)(4\phantom{)}
2)(22)(2
(3)\phantom{(}3)
==
(4)(4\phantom{)}
(3)\phantom{(}3)

When a question describes two maps in words, write down their matrix sizes in right-to-left multiplication order TSTS before doing any arithmetic. If the two inner numbers don't match, either the matrices are written in the wrong order or the composition isn't possible.

Key concepts

When you chain linear maps together, read the steps from right to left: doing SS first and TT second is the composition T∘ST \circ S, and its matrix is the product TSTS. To find each column of TSTS, apply TT to the matching column of SS, like [1320][2−112]=[554−2]\begin{bmatrix} \acting{1} & \acting{3} \\ \acting{2} & \acting{0} \end{bmatrix}\begin{bmatrix} \firstcol{2} & \secondcol{-1} \\ \firstcol{1} & \secondcol{2} \end{bmatrix} = \begin{bmatrix} \firstcol{5} & \secondcol{5} \\ \firstcol{4} & \secondcol{-2} \end{bmatrix}. And if a problem already tells you where SS sends (1,0)\firstcol{(1, 0)} and (0,1)\secondcol{(0, 1)} and where TT sends those two landing spots, you don't need the matrix of TT because those final spots are already the columns of T∘ST \circ S.

Because the order sets which map acts first, ABAB and BABA are usually different maps (RF=[0110]RF = \begin{bmatrix} \firstcol{0} & \secondcol{1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix} reflects across y=xy = x, while FR=[0−1−10]FR = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{-1} & \secondcol{0} \end{bmatrix} reflects across y=−xy = -x). Regrouping (AB)C=A(BC)(AB)C = A(BC), on the other hand, keeps the order C→B→AC \to B \to A the same, so you can combine an easy pair of steps first instead of writing out every matrix. Finally, a map from nDn\text{D} to mDm\text{D} has an m×nm \times n matrix (output rows×input columns\text{output rows} \times \text{input columns}), and TSTS only works when the inner numbers match, like (4×2)(2×3)=4×3(4 \times 2)(2 \times 3) = 4 \times 3.

4

Practice

1

The first linear map SS has matrix [123−1]\begin{bmatrix} 1 & 2 \\ 3 & -1 \end{bmatrix} and the second linear map TT has matrix [2014]\begin{bmatrix} 2 & 0 \\ 1 & 4 \end{bmatrix}. Find the matrix for the combined map T∘ST \circ S (doing SS first, then TT).

In T(S(x))T(S(\thevector{x})), which map acts on x\thevector{x} first, and which side of the matrix product does that matrix sit on?

Since SS happens first and TT happens second, put SS on the right and TT on the left:
TS=[2014][123−1]\displaystyle TS = \begin{bmatrix} \acting{2} & \acting{0} \\ \acting{1} & \acting{4} \end{bmatrix}\begin{bmatrix} \firstcol{1} & \secondcol{2} \\ \firstcol{3} & \secondcol{-1} \end{bmatrix}
(Watch out: multiplying in the order the matrices are mentioned in the sentence gives ST=[123−1][2014]=[485−4]ST = \begin{bmatrix} 1 & 2 \\ 3 & -1 \end{bmatrix}\begin{bmatrix} 2 & 0 \\ 1 & 4 \end{bmatrix} = \begin{bmatrix} 4 & 8 \\ 5 & -4 \end{bmatrix}, which does TT first and SS second.)
Applying TT to the first column (1,3)\firstcol{(1, 3)} gives 1[21]+3[04]=[213]\firstcol{1}\begin{bmatrix} \acting{2} \\ \acting{1} \end{bmatrix} + \firstcol{3}\begin{bmatrix} \acting{0} \\ \acting{4} \end{bmatrix} = \begin{bmatrix} \firstcol{2} \\ \firstcol{13} \end{bmatrix}, and applying TT to the second column (2,−1)\secondcol{(2, -1)} gives 2[21]−1[04]=[4−2]\secondcol{2}\begin{bmatrix} \acting{2} \\ \acting{1} \end{bmatrix} - \secondcol{1}\begin{bmatrix} \acting{0} \\ \acting{4} \end{bmatrix} = \begin{bmatrix} \secondcol{4} \\ \secondcol{-2} \end{bmatrix}, so:
TS=[2413−2]\displaystyle TS = \begin{bmatrix} \firstcol{2} & \secondcol{4} \\ \firstcol{13} & \secondcol{-2} \end{bmatrix}
2

Let FF be a reflection across the yy-axis and RR be a 90∘90^\circ counterclockwise rotation. Write the matrices for FF and RR, find the matrices for R∘FR \circ F and F∘RF \circ R, and describe what single geometric map each composition is.

Track where the starting basis vectors (1,0)(1, 0) and (0,1)(0, 1) land under a yy-axis reflection to write FF, then read off from the columns of RFRF and FRFR where each one sends (1,0)(1, 0) and (0,1)(0, 1).

Reflecting across the vertical yy-axis flips the horizontal vector (1,0)\firstcol{(1, 0)} to (−1,0)\firstcol{(-1, 0)} and leaves (0,1)\secondcol{(0, 1)} on the yy-axis unchanged, while rotating 90∘90^\circ counterclockwise sends (1,0)\firstcol{(1, 0)} to (0,1)\firstcol{(0, 1)} and (0,1)\secondcol{(0, 1)} to (−1,0)\secondcol{(-1, 0)}:
F=[−1001],R=[0−110]\displaystyle F = \begin{bmatrix} \firstcol{-1} & \secondcol{0} \\ \firstcol{0} & \secondcol{1} \end{bmatrix}, \qquad R = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}
(Watch out: using the xx-axis reflection matrix [100−1]\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} for FF swaps the two products below, giving [0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} for RFRF and [0−1−10]\begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix} for FRFR.)
For R∘FR \circ F (FF first, RR second):
RF=[0−110][−1001]=[0−1−10]\displaystyle RF = \begin{bmatrix} \acting{0} & \acting{-1} \\ \acting{1} & \acting{0} \end{bmatrix}\begin{bmatrix} \firstcol{-1} & \secondcol{0} \\ \firstcol{0} & \secondcol{1} \end{bmatrix} = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{-1} & \secondcol{0} \end{bmatrix}
which sends (1,0)\firstcol{(1, 0)} to (0,−1)\firstcol{(0, -1)} and (0,1)\secondcol{(0, 1)} to (−1,0)\secondcol{(-1, 0)}, a reflection across the line y=−xy = -x.
For F∘RF \circ R (RR first, FF second):
FR=[−1001][0−110]=[0110]\displaystyle FR = \begin{bmatrix} \acting{-1} & \acting{0} \\ \acting{0} & \acting{1} \end{bmatrix}\begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix} = \begin{bmatrix} \firstcol{0} & \secondcol{1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}
which swaps (1,0)\firstcol{(1, 0)} and (0,1)\secondcol{(0, 1)}, a reflection across the line y=xy = x.
3

A linear map SS takes 2D vectors to 5D vectors, and a linear map TT takes 3D vectors to 2D vectors. What size is the matrix for each map? Which composition, T∘ST \circ S or S∘TS \circ T, makes sense, and what size is its matrix?

Each starting basis vector in the input space gives a column, and each coordinate in the output space gives a row; then check which map's outputs can go into the other map's inputs.

SS has 5D outputs and 2D inputs, so SS is a 5×25 \times 2 matrix; TT has 2D outputs and 3D inputs, so TT is a 2×32 \times 3 matrix.
(Watch out: writing the sizes as input×output\text{input} \times \text{output} gives 2×52 \times 5 for SS and 3×23 \times 2 for TT, which makes it look like T∘ST \circ S works with size (3×2)(2×5)=3×5(3 \times 2)(2 \times 5) = 3 \times 5.)
Only S∘TS \circ T (doing TT first, then SS) makes sense because TT outputs 2D vectors, matching the 2D input space of SS (whereas T∘ST \circ S would try to plug 5D outputs from SS into TT's 3D input space). The matrix STST has size (5×2)(2×3)=5×3(5 \times 2)(2 \times 3) = 5 \times 3.
4

A linear map SS sends (1,0)(1, 0) to (2,−1)(2, -1) and (0,1)(0, 1) to (1,3)(1, 3). A second linear map TT sends (2,−1)(2, -1) to (4,0)(4, 0) and (1,3)(1, 3) to (−2,5)(-2, 5). Without finding the matrix for TT, find the matrix for T∘ST \circ S and find where T∘ST \circ S sends the vector (3,2)\thevector{(3, 2)}.

What do the columns of any linear map's matrix record, and where do (1,0)(1, 0) and (0,1)(0, 1) land after going through SS and then TT?

Under SS followed by TT, the first basis vector (1,0)\firstcol{(1, 0)} goes to (2,−1)\firstcol{(2, -1)} and then straight to (4,0)\firstcol{(4, 0)}, while the second basis vector (0,1)\secondcol{(0, 1)} goes to (1,3)\secondcol{(1, 3)} and then straight to (−2,5)\secondcol{(-2, 5)}. Putting those two final landing spots into columns gives:
Matrix of (T∘S)=[4−205]\displaystyle \text{Matrix of }(T \circ S) = \begin{bmatrix} \firstcol{4} & \secondcol{-2} \\ \firstcol{0} & \secondcol{5} \end{bmatrix}
(Watch out: treating [4−205]\begin{bmatrix} 4 & -2 \\ 0 & 5 \end{bmatrix} as the matrix of TT and multiplying it by S=[21−13]S = \begin{bmatrix} 2 & 1 \\ -1 & 3 \end{bmatrix} gives [10−2−515]\begin{bmatrix} 10 & -2 \\ -5 & 15 \end{bmatrix} and sends (3,2)(3, 2) to (26,15)(26, 15), because (4,0)(4, 0) and (−2,5)(-2, 5) are already where TT sends the columns of SS, not where TT sends (1,0)(1, 0) and (0,1)(0, 1).)
Applying T∘ST \circ S to (3,2)\thevector{(3, 2)} gives:
(T∘S)(3,2)=3[40]+2[−25]=[810]\displaystyle (T \circ S)(\thevector{3, 2}) = \firstcol{3}\begin{bmatrix} \firstcol{4} \\ \firstcol{0} \end{bmatrix} + \secondcol{2}\begin{bmatrix} \secondcol{-2} \\ \secondcol{5} \end{bmatrix} = \begin{bmatrix} \thevector{8} \\ \thevector{10} \end{bmatrix}
5

A three-step map reflects across the xx-axis (FF), then rotates 30∘30^\circ counterclockwise (R30R_{30}), and then rotates 60∘60^\circ counterclockwise (R60R_{60}). Regroup the parentheses to find the single 2×22 \times 2 matrix for the combined map R60∘(R30∘F)R_{60} \circ (R_{30} \circ F) without finding the individual matrices for R30R_{30} and R60R_{60}.

How can you regroup R60(R30F)R_{60}(R_{30}F) so that the two rotations combine into a single familiar rotation first?

Regrouping the parentheses gives R60(R30F)=(R60R30)FR_{60}(R_{30}F) = (R_{60}R_{30})F. Rotating by 30∘30^\circ counterclockwise and then by 60∘60^\circ counterclockwise combines into a single 90∘90^\circ counterclockwise rotation R90=[0−110]R_{90} = \begin{bmatrix} \firstcol{0} & \secondcol{-1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}, and the xx-axis reflection is F=[100−1]F = \begin{bmatrix} \firstcol{1} & \secondcol{0} \\ \firstcol{0} & \secondcol{-1} \end{bmatrix}.
(Watch out: multiplying in the left-to-right order of the description gives FR90=[100−1][0−110]FR_{90} = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} =[0−1−10]{}= \begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}; since FF happens first, FF must stay on the right.)
Multiplying R90FR_{90}F gives:
R90F=[0−110][100−1]=[0110]\displaystyle R_{90}F = \begin{bmatrix} \acting{0} & \acting{-1} \\ \acting{1} & \acting{0} \end{bmatrix}\begin{bmatrix} \firstcol{1} & \secondcol{0} \\ \firstcol{0} & \secondcol{-1} \end{bmatrix} = \begin{bmatrix} \firstcol{0} & \secondcol{1} \\ \firstcol{1} & \secondcol{0} \end{bmatrix}