Tutorials › Linear Algebra › Why Composition Multiplies Standard Matrices

Linear Transformations of R^n · Tutorial 204 of 1000

Why Composition Multiplies Standard Matrices

See how evaluating a composite transformation on each standard basis vector gives the product \(BA\), and practise checking the dimensions and calculations.

Intermediate 9 min read

What You'll Learn

  • Define the standard matrix of a linear transformation using the images of the standard basis vectors.
  • Show how a standard matrix acts on an arbitrary input vector.
  • Prove that composing transformations with matrices A and B gives the matrix product BA.
  • Track the dimensions required for a matrix product representing a composition.
  • Check composite matrices by evaluating basis vectors and selected inputs.
  • Identify and correct a mistaken reversal of the order of matrix multiplication.

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.

Definition: If \(T:\mathbb{R}^n\to\mathbb{R}^m\) is linear, its standard matrix is \(\mathbf{A}=\begin{bmatrix}T(\mathbf{e}_1)&\cdots&T(\mathbf{e}_n)\end{bmatrix}\in\mathbb{R}^{m\times n}\). Its \(j\)th column is the vector \(T(\mathbf{e}_j)\).

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}\).

Proposition: If \(\mathbf{A}\) is the standard matrix of \(T:\mathbb{R}^n\to\mathbb{R}^m\), then \(T(\mathbf{x})=\mathbf{A}\mathbf{x}\) for every \(\mathbf{x}\in\mathbb{R}^n\).

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}\).

Proposition: If \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{p\times m}\), then the \(j\)th column of \(\mathbf{B}\mathbf{A}\) is \(\mathbf{B}\mathbf{a}_j\), or, equivalently, \(\sum_{k=1}^{m}a_{kj}\mathbf{b}_k\).

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\)

Theorem (Matrix of a composition): Let \(T:\mathbb{R}^n\to\mathbb{R}^m\) and \(S:\mathbb{R}^m\to\mathbb{R}^p\) be linear, with standard matrices \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{p\times m}\), respectively. Then the standard matrix of \(S\circ T\) is \(\mathbf{B}\mathbf{A}\).

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

$$ \mathbf{A}=\begin{bmatrix}1&2\\-1&0\\3&4\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}1&0&-1\\0&1&\tfrac12\end{bmatrix}. $$

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

$$ (S\circ T)(\mathbf{e}_1) =\begin{bmatrix}1\\0\end{bmatrix} -\begin{bmatrix}0\\1\end{bmatrix} +3\begin{bmatrix}-1\\\tfrac12\end{bmatrix} =\begin{bmatrix}-2\\\tfrac12\end{bmatrix}. $$

Next, \(T(\mathbf{e}_2)=(2,0,4)^{\top}\), giving

$$ (S\circ T)(\mathbf{e}_2) =2\begin{bmatrix}1\\0\end{bmatrix} +4\begin{bmatrix}-1\\\tfrac12\end{bmatrix} =\begin{bmatrix}-2\\2\end{bmatrix}. $$

These two output vectors are the columns of the standard matrix of the composite. Direct multiplication confirms the result:

$$ \mathbf{B}\mathbf{A} =\begin{bmatrix}1&0&-1\\0&1&\tfrac12\end{bmatrix} \begin{bmatrix}1&2\\-1&0\\3&4\end{bmatrix} =\begin{bmatrix}-2&-2\\\tfrac12&2\end{bmatrix}. $$

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

$$ \mathbf{A}=\begin{bmatrix}1&2\\0&1\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}2&0\\1&1\end{bmatrix}. $$

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

$$ (S\circ T)(\mathbf{e}_1)=S(\mathbf{e}_1)=\begin{bmatrix}2\\1\end{bmatrix}, \qquad (S\circ T)(\mathbf{e}_2)=2S(\mathbf{e}_1)+S(\mathbf{e}_2) =\begin{bmatrix}4\\3\end{bmatrix}. $$

Thus the standard matrix has these two columns. Multiplication gives the same result:

$$ \mathbf{B}\mathbf{A} =\begin{bmatrix}2&0\\1&1\end{bmatrix} \begin{bmatrix}1&2\\0&1\end{bmatrix} =\begin{bmatrix}2&4\\1&3\end{bmatrix}. $$

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

$$ \mathbf{A}=\begin{bmatrix}1&0&2\\0&1&-1\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}2&-1\end{bmatrix}. $$

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:

$$ \mathbf{B}\mathbf{A} =\begin{bmatrix}2&-1\end{bmatrix} \begin{bmatrix}1&0&2\\0&1&-1\end{bmatrix} =\begin{bmatrix}2&-1&5\end{bmatrix}. $$

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

$$ \mathbf{A}\mathbf{B} =\begin{bmatrix}1&2&0\\-1&0&1\\3&4&-1\end{bmatrix}. $$

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.

  1. 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\)?
  2. Explain why the \(j\)th column of the standard matrix of \(S\circ T\) is \(S(T(\mathbf{e}_j))\).
  3. 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.
  4. 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.
  5. 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}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon