From Composing Maps to Multiplying Matrices
A matrix records where a linear transformation sends the standard basis vectors. That makes it possible to find the matrix of a composition by asking a direct question: where does the composite send each basis vector? The answer explains why, if \(T\) has standard matrix \(\mathbf{A}\) and \(S\) has standard matrix \(\mathbf{B}\), the standard matrix of \(S\circ T\) is \(\mathbf{B}\mathbf{A}\), in that order.
Throughout, the scalar field is \(\mathbb{R}\). Let \(T:\mathbb{R}^n\to\mathbb{R}^m\) be linear. Its standard matrix has one column for each standard basis vector in the input space. If \(S:\mathbb{R}^m\to\mathbb{R}^p\) is another linear transformation, then \(S\circ T:\mathbb{R}^n\to\mathbb{R}^p\) is defined by \((S\circ T)(\mathbf{x})=S(T(\mathbf{x}))\). The output of \(T\) is in the input space of \(S\), so this composition is defined.
Each vector \(\mathbf{x}\in\mathbb{R}^n\) can be written as \(\mathbf{x}=x_1\mathbf{e}_1+\cdots+x_n\mathbf{e}_n\). Linearity then determines \(T(\mathbf{x})\) from the columns of \(\mathbf{A}\).
Proof. Write \(\mathbf{x}=x_1\mathbf{e}_1+\cdots+x_n\mathbf{e}_n\). By linearity, \(T(\mathbf{x})=x_1T(\mathbf{e}_1)+\cdots+x_nT(\mathbf{e}_n)\). The vectors \(T(\mathbf{e}_1),\dots,T(\mathbf{e}_n)\) are the columns of \(\mathbf{A}\), so this linear combination is precisely the matrix-vector product \(\mathbf{A}\mathbf{x}\). \(\square\)
Why the Product Is \(\mathbf{B}\mathbf{A}\)
Suppose \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{p\times m}\). Then \(\mathbf{B}\mathbf{A}\) is defined and has size \(p\times n\), just the size needed for a standard matrix from \(\mathbb{R}^n\) to \(\mathbb{R}^p\). The dimensions are part of the explanation: the \(m\) outputs of \(T\) are exactly the \(m\) inputs expected by \(S\).
To see what a product column means, write the columns of \(\mathbf{A}\) as \(\mathbf{a}_1,\dots,\mathbf{a}_n\), and the columns of \(\mathbf{B}\) as \(\mathbf{b}_1,\dots,\mathbf{b}_m\). The \(j\)th column of \(\mathbf{B}\mathbf{A}\) is \(\mathbf{B}\mathbf{a}_j\), the image under \(S\)'s matrix of the \(j\)th column of \(\mathbf{A}\).
Proof. By the definition of matrix multiplication, the entry in row \(i\), column \(j\) of \(\mathbf{B}\mathbf{A}\) is \(\sum_{k=1}^{m}b_{ik}a_{kj}\). The \(i\)th entry of \(\sum_{k=1}^{m}a_{kj}\mathbf{b}_k\) is also \(\sum_{k=1}^{m}a_{kj}b_{ik}\). These entries agree for each row \(i\), so the \(j\)th column is that linear combination of the columns of \(\mathbf{B}\). Since the \(j\)th column of \(\mathbf{A}\) is \(\mathbf{a}_j\), the same column is \(\mathbf{B}\mathbf{a}_j\). \(\square\)
Proof. The standard matrix of \(S\circ T\) has \(j\)th column \((S\circ T)(\mathbf{e}_j)\), for each \(j=1,\dots,n\). By the definition of composition, this is \(S(T(\mathbf{e}_j))\). Since the \(j\)th column of \(\mathbf{A}\) is \(T(\mathbf{e}_j)\), the standard-matrix formula for \(S\) gives \(S(T(\mathbf{e}_j))=\mathbf{B}T(\mathbf{e}_j)=\mathbf{B}\mathbf{a}_j\). By the proposition, \(\mathbf{B}\mathbf{a}_j\) is the \(j\)th column of \(\mathbf{B}\mathbf{A}\). This holds for every \(j=1,\dots,n\), so the standard matrices of \(S\circ T\) and \(\mathbf{B}\mathbf{A}\) have the same columns. Therefore they are equal. \(\square\)
Worked Examples
Worked Example: A Composition Between Different Dimensions
Let \(T:\mathbb{R}^2\to\mathbb{R}^3\) have standard matrix \(\mathbf{A}\), and let \(S:\mathbb{R}^3\to\mathbb{R}^2\) have standard matrix \(\mathbf{B}\), where
The dimensions are \(\mathbf{A}\in\mathbb{R}^{3\times2}\) and \(\mathbf{B}\in\mathbb{R}^{2\times3}\), so \(\mathbf{B}\mathbf{A}\) is a \(2\times2\) matrix. Evaluate the composite on each standard basis vector in \(\mathbb{R}^2\). First, \(T(\mathbf{e}_1)=(1,-1,3)^{\top}\). The columns of \(\mathbf{B}\) are \((1,0)^{\top},(0,1)^{\top},(-1,\tfrac12)^{\top}\), so
Next, \(T(\mathbf{e}_2)=(2,0,4)^{\top}\), giving
These two output vectors are the columns of the standard matrix of the composite. Direct multiplication confirms the result:
Check: for \(\mathbf{x}=(2,-1)^{\top}\), \(\mathbf{A}\mathbf{x}=(0,-2,2)^{\top}\), and \(\mathbf{B}\mathbf{A}\mathbf{x}=(-2,-1)^{\top}\). Directly, \((\mathbf{B}\mathbf{A})\mathbf{x}=(-4+2,1-2)^{\top}=(-2,-1)^{\top}\), as required.
Worked Example: A Composition on \(\mathbb{R}^2\)
Suppose \(T:\mathbb{R}^2\to\mathbb{R}^2\) and \(S:\mathbb{R}^2\to\mathbb{R}^2\) have standard matrices
The first column of \(\mathbf{A}\) gives \(T(\mathbf{e}_1)=(1,0)^{\top}\), and the second gives \(T(\mathbf{e}_2)=(2,1)^{\top}\). Since \(S(\mathbf{e}_1)=(2,1)^{\top}\) and \(S(\mathbf{e}_2)=(0,1)^{\top}\), linearity gives
Thus the standard matrix has these two columns. Multiplication gives the same result:
Check: take \(\mathbf{x}=(1,-1)^{\top}\). Then \(\mathbf{A}\mathbf{x}=(-1,-1)^{\top}\), and applying \(\mathbf{B}\) gives \((-2,-2)^{\top}\). Also \((\mathbf{B}\mathbf{A})\mathbf{x}=(2-4,1-3)^{\top}=(-2,-2)^{\top}\).
Worked Example: A Composite With One-Dimensional Output
Let \(T:\mathbb{R}^3\to\mathbb{R}^2\) have standard matrix \(\mathbf{A}\), and let \(S:\mathbb{R}^2\to\mathbb{R}\) have standard matrix \(\mathbf{B}\), where
Here \(\mathbf{B}\mathbf{A}\) has size \(1\times3\). The columns of \(\mathbf{A}\) show that \(T(\mathbf{e}_1)=(1,0)^{\top}\), \(T(\mathbf{e}_2)=(0,1)^{\top}\), and \(T(\mathbf{e}_3)=(2,-1)^{\top}\). Applying \(S\), whose rule on \((u,v)^{\top}\) is \(2u-v\), gives composite outputs \(2,-1,\) and \(5\), respectively. Therefore its standard matrix is \(\begin{bmatrix}2&-1&5\end{bmatrix}\).
Direct multiplication verifies this:
Check: for \(\mathbf{x}=(1,-2,3)^{\top}\), first \(T(\mathbf{x})=(1+6,-2-3)^{\top}=(7,-5)^{\top}\), then \(S(T(\mathbf{x}))=14+5=19\). The product gives \((\mathbf{B}\mathbf{A})\mathbf{x}=2+2+15=19\).
Dimensions and a Common Mistake
The sizes of the matrices track the input and output spaces: if \(T:\mathbb{R}^n\to\mathbb{R}^m\), then \(\mathbf{A}\) has \(m\) rows and \(n\) columns. If \(S:\mathbb{R}^m\to\mathbb{R}^p\), then \(\mathbf{B}\) has \(p\) rows and \(m\) columns. The matching \(m\) makes \(\mathbf{B}\mathbf{A}\) defined, with \(p\) rows and \(n\) columns. It is not enough to remember a multiplication order; check that the inner dimensions match and that the output has the correct size.
Common mistake: reversing the order or declaring a valid product undefined. In the first example, \(\mathbf{A}\) is \(3\times2\) and \(\mathbf{B}\) is \(2\times3\). It would be wrong to say \(\mathbf{A}\mathbf{B}\) is undefined: the inner dimensions are both \(2\), so that product is defined and has size \(3\times3\). In fact, direct multiplication gives
This is not the matrix of \(S\circ T\), which maps \(\mathbb{R}^2\) to \(\mathbb{R}^2\) and therefore has a \(2\times2\) standard matrix. The product \(\mathbf{A}\mathbf{B}\) instead has the dimensions of a map from \(\mathbb{R}^3\) to \(\mathbb{R}^3\); it represents \(T\circ S\), which applies \(S\) first and then \(T\). In this example, both orders of multiplication are defined, but they represent compositions with different domains and outputs.
Another useful check is to compare the columns: the \(j\)th column of the matrix of \(S\circ T\) must be \(S(T(\mathbf{e}_j))\). If a proposed matrix product does not have these columns or the required size, it cannot be the standard matrix of that composite.
Why This Rule Is Useful
The composition rule turns successive linear operations into one matrix operation. For an input \(\mathbf{x}\), the first transformation gives \(\mathbf{A}\mathbf{x}\); applying the second gives \(\mathbf{B}(\mathbf{A}\mathbf{x})=(\mathbf{B}\mathbf{A})\mathbf{x}\). Thus the matrix product summarizes the full composite, while the basis-vector proof explains why that summary has exactly the right columns. This is useful whenever transformations are described in stages: identify each map's input and output spaces, write its standard matrix, and multiply in the order dictated by applying the maps.
Check Your Understanding
For each question, keep track of both the transformation being applied and the dimensions of its matrix.
- If \(T:\mathbb{R}^4\to\mathbb{R}^2\) has standard matrix \(\mathbf{A}\) and \(S:\mathbb{R}^2\to\mathbb{R}^3\) has standard matrix \(\mathbf{B}\), what are the sizes of \(\mathbf{A}\), \(\mathbf{B}\), and the standard matrix of \(S\circ T\)?
- Explain why the \(j\)th column of the standard matrix of \(S\circ T\) is \(S(T(\mathbf{e}_j))\).
- Let \(\mathbf{A}=\begin{bmatrix}1&0\\2&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}1&1\\0&2\end{bmatrix}\). Compute \(\mathbf{B}\mathbf{A}\) and state the images of \(\mathbf{e}_1,\mathbf{e}_2\) under the composite.
- If \(\mathbf{A}\) is \(3\times2\) and \(\mathbf{B}\) is \(2\times3\), determine whether \(\mathbf{B}\mathbf{A}\) and \(\mathbf{A}\mathbf{B}\) are defined, and give the size of each.
- For \(T:\mathbb{R}^n\to\mathbb{R}^m\) with standard matrix \(\mathbf{A}\), explain in one or two lines why \(T(\mathbf{x})=\mathbf{A}\mathbf{x}\).