Tutorials › Linear Algebra › Rectangular Matrix Shapes from Domain and Codomain Dimensions

Matrix Representations of Linear Maps · Tutorial 431 of 1000

Rectangular Matrix Shapes from Domain and Codomain Dimensions

Use the dimensions of the domain and codomain to determine a representing matrix’s shape and check coordinate-vector products.

Intermediate 9 min read

What You'll Learn

  • Match the number of matrix columns to the domain dimension.
  • Match the number of matrix rows to the codomain dimension.
  • Check that a domain coordinate vector can be multiplied by its representing matrix.
  • Read the output length from the codomain dimension.
  • Recognize when a representation must be rectangular or square.

Why Matrix Shape Records the Direction of a Map

A matrix representing a linear map has a shape determined by the spaces the map connects. Its columns correspond to directions in the domain, while its rows record coordinates in the codomain. Getting that shape right is not cosmetic: it determines whether the matrix can act on an input coordinate vector at all, and how many entries the output coordinate vector will have.

Throughout this tutorial, the scalar field is \(\mathbb{R}\), and the vector spaces under discussion are finite-dimensional. Let \(T:V\to W\) be a linear map, with \(\dim V=n\) and \(\dim W=m\). Choose ordered bases \(\mathcal{B}=(\mathbf{b}_1,\dots,\mathbf{b}_n)\) for \(V\) and \(\mathcal{C}=(\mathbf{c}_1,\dots,\mathbf{c}_m)\) for \(W\). The coordinate vector \([\mathbf{v}]_{\mathcal{B}}\) is the column of coefficients expressing \(\mathbf{v}\) in the basis \(\mathcal{B}\); it has \(n\) entries. A coordinate vector in the basis \(\mathcal{C}\) has \(m\) entries.

Definition: The matrix representation \([T]_{\mathcal{C}\leftarrow\mathcal{B}}\) is the matrix whose \(j\)th column is \([T(\mathbf{b}_j)]_{\mathcal{C}}\). It represents \(T\) using input coordinates in \(\mathcal{B}\) and output coordinates in \(\mathcal{C}\).

Each column is a coordinate vector in \(W\), so each column has \(m\) entries. There is one column for each of the \(n\) basis vectors of \(V\). This gives the central shape rule.

Theorem (Shape of a matrix representation): If \(T:V\to W\), \(\dim V=n\), and \(\dim W=m\), then for any ordered basis \(\mathcal{B}\) of \(V\) and ordered basis \(\mathcal{C}\) of \(W\), the matrix \([T]_{\mathcal{C}\leftarrow\mathcal{B}}\) has \(m\) rows and \(n\) columns. In particular, its shape is \(m\times n\).

Proof. Write \(\mathcal{B}=(\mathbf{b}_1,\dots,\mathbf{b}_n)\) and \(\mathcal{C}=(\mathbf{c}_1,\dots,\mathbf{c}_m)\). By definition, column \(j\) of the representing matrix is \([T(\mathbf{b}_j)]_{\mathcal{C}}\). Because this is a coordinate vector in a basis with \(m\) elements, it has \(m\) entries. The columns are indexed by \(j=1,\dots,n\), so there are \(n\) columns. Thus the matrix has \(m\) rows and \(n\) columns. \(\square\)

The arrow \(\mathcal{C}\leftarrow\mathcal{B}\) is a useful reminder of the direction: coordinates enter in the domain basis \(\mathcal{B}\), and the result is expressed in the codomain basis \(\mathcal{C}\). The number of columns comes from the domain; the number of rows comes from the codomain. This remains true when \(m\ne n\), so a representing matrix need not be square.

Input and Output Coordinate Lengths

The shape rule also predicts whether the matrix-vector product is defined. An input \(\mathbf{v}\in V\) has coordinate vector \([\mathbf{v}]_{\mathcal{B}}\in\mathbb{R}^n\), written as a column. The representing matrix has \(n\) columns, so its columns match the \(n\) entries in the input coordinate vector. The product has \(m\) entries, matching the \(m\) coordinates needed to describe \(T(\mathbf{v})\in W\).

Theorem (Coordinate-vector compatibility): Under the hypotheses above, for every \(\mathbf{v}\in V\), $$ [T(\mathbf{v})]_{\mathcal{C}} = [T]_{\mathcal{C}\leftarrow\mathcal{B}}[\mathbf{v}]_{\mathcal{B}}, $$ where the matrix is \(m\times n\), the input coordinate vector has length \(n\), and the output coordinate vector has length \(m\).

Proof. Write \([\mathbf{v}]_{\mathcal{B}}=(x_1,\dots,x_n)^{\top}\), so by the definition of coordinates, \(\mathbf{v}=\sum_{j=1}^{n}x_j\mathbf{b}_j\). Linearity gives \(T(\mathbf{v})=\sum_{j=1}^{n}x_jT(\mathbf{b}_j)\). Taking coordinates in \(\mathcal{C}\) preserves linear combinations, so $$ [T(\mathbf{v})]_{\mathcal{C}} = \sum_{j=1}^{n}x_j[T(\mathbf{b}_j)]_{\mathcal{C}}. $$ The vectors \([T(\mathbf{b}_j)]_{\mathcal{C}}\) are precisely the columns of \([T]_{\mathcal{C}\leftarrow\mathcal{B}}\). By the definition of matrix-vector multiplication, their linear combination with coefficients \(x_1,\dots,x_n\) is \([T]_{\mathcal{C}\leftarrow\mathcal{B}}[\mathbf{v}]_{\mathcal{B}}\). This product has \(m\) entries because each of the \(m\) rows produces one entry. Hence it is the coordinate vector of \(T(\mathbf{v})\) in \(\mathcal{C}\). \(\square\)

In general, multiplying an \(m\times n\) matrix by a column vector requires that the vector have \(n\) entries, and the result has \(m\) entries. Each output entry is the dot product of one matrix row, of length \(n\), with the input column, also of length \(n\). This is the same compatibility required by the representation theorem, not a separate convention.

Worked Examples: Reading the Shape from the Spaces

Worked Example: A Map from a Two-Dimensional Space to a Three-Dimensional Space

Let \(V=P_1\), the real polynomials of degree at most \(1\), and \(W=\mathbb{R}^3\). Use \(\mathcal{B}=(1+x,1-x)\) for \(V\) and the standard basis for \(W\). Suppose \(T(1+x)=(1,0,2)^{\top}\) and \(T(1-x)=(0,1,-1)^{\top}\). Determine the matrix shape and find the output coordinates for an input with \([\mathbf{v}]_{\mathcal{B}}=(2,-1)^{\top}\).

The domain has dimension \(2\), and the codomain has dimension \(3\), so the representing matrix must be \(3\times2\). Its columns are the given images in codomain coordinates:

$$ [T]_{\mathcal{C}\leftarrow\mathcal{B}} = \begin{bmatrix} 1&0\\ 0&1\\ 2&-1 \end{bmatrix}. $$

Multiply by the two-entry input coordinate vector. The three row calculations are \(1(2)+0(-1)=2\), \(0(2)+1(-1)=-1\), and \(2(2)+(-1)(-1)=5\), so

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

Check: The input represents \(\mathbf{v}=2(1+x)-(1-x)=1+3x\). By linearity, \(T(\mathbf{v})=2(1,0,2)^{\top}-(0,1,-1)^{\top}=(2,-1,5)^{\top}\), exactly the coordinate vector found by multiplication. The output has three entries, as required for \(\mathbb{R}^3\).

Worked Example: A Map from Three Coordinates to a Polynomial Space

Let \(T:\mathbb{R}^3\to P_1\), use the standard basis in \(\mathbb{R}^3\), and let the codomain basis be \(\mathcal{C}=(1+x,1-x)\). Suppose the images of the three domain basis vectors have \(\mathcal{C}\)-coordinate vectors \((1,0)^{\top}\), \((0,-1)^{\top}\), and \((2,1)^{\top}\), respectively. Find the output coordinates for input \(\mathbf{x}=(2,-1,3)^{\top}\).

There are three domain basis vectors and two codomain basis vectors, so the representing matrix has three columns and two rows:

$$ [T]_{\mathcal{C}\leftarrow\mathcal{B}} = \begin{bmatrix} 1&0&2\\ 0&-1&1 \end{bmatrix}. $$

The input column has three entries, matching the three matrix columns. Multiplying row by row gives \(1(2)+0(-1)+2(3)=8\) and \(0(2)+(-1)(-1)+1(3)=4\):

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

Check: The output polynomial represented by these coordinates is \(8(1+x)+4(1-x)=12+4x\). From the prescribed basis images, \(T(\mathbf{x})=2(1+x)-[-(1-x)]+3[2(1+x)+(1-x)]\). Expanding gives \(2+2x+1-x+9+3x=12+4x\), which agrees. Its coordinate vector has two entries because the codomain basis has two elements.

Worked Example: A Map from a Four-Dimensional Matrix Space to \(\mathbb{R}^2\)

Let \(V=M_{2\times2}(\mathbb{R})\), whose basis is \(\mathcal{B}=(E_{11},E_{12},E_{21},E_{22})\), where \(E_{ij}\) has a \(1\) in position \((i,j)\) and zeros elsewhere. Let the codomain be \(\mathbb{R}^2\) with its standard basis. Suppose the images of the four basis matrices are, in order, \((1,0)^{\top}\), \((0,1)^{\top}\), \((1,2)^{\top}\), and \((-1,1)^{\top}\). Find the output for the matrix \(X=\begin{bmatrix}1&-2\\0&3\end{bmatrix}\).

The domain dimension is \(4\), while the codomain dimension is \(2\). The representation is therefore \(2\times4\). The coordinate vector of \(X\) in the stated basis lists its entries in the basis order: \([X]_{\mathcal{B}}=(1,-2,0,3)^{\top}\). Thus

$$ [T]_{\mathcal{C}\leftarrow\mathcal{B}} = \begin{bmatrix} 1&0&1&-1\\ 0&1&2&1 \end{bmatrix}, \qquad \begin{bmatrix} 1&0&1&-1\\ 0&1&2&1 \end{bmatrix} \begin{bmatrix}1\\-2\\0\\3\end{bmatrix} = \begin{bmatrix}-2\\1\end{bmatrix}. $$

The first output entry is \(1(1)+0(-2)+1(0)+(-1)(3)=-2\). The second is \(0(1)+1(-2)+2(0)+1(3)=1\).

Check: Linearity and the prescribed images give \(T(X)=(1,0)-2(0,1)+0(1,2)+3(-1,1)=(-2,1)\). This is the same result as the matrix product, and it has two entries, matching the codomain dimension.

Rectangular and Square Shapes

If \(m>n\), then the representation has more rows than columns: the codomain has more basis coordinates than the domain has input coordinates. If \(m<n\), it has more columns than rows. Neither case prevents the matrix from representing a linear map; multiplication only requires that the input coordinate vector have length \(n\).

The matrix is square exactly when \(m=n\), because it then has \(n\) rows and \(n\) columns. Shape alone says only that the domain and codomain have equal dimensions. It does not, by itself, establish that a particular map is one-to-one or onto, nor that its representing matrix has an inverse. Those are claims about the map or matrix entries, not consequences of counting rows and columns alone.

The same counting rule includes zero-dimensional spaces. If the domain has dimension \(0\), there are no domain basis vectors and hence no columns; if the codomain has dimension \(0\), each column has no entries and hence there are no rows. The shape remains \(m\times n\), with the row count determined by the codomain and the column count by the domain.

Common Mistake: Reversing the Dimensions

A frequent error is to write the codomain dimension as the number of columns and the domain dimension as the number of rows. For a map \(T:\mathbb{R}^3\to P_1\), that reversal would suggest a \(3\times2\) matrix. But an input coordinate vector has three entries, so a \(3\times2\) matrix cannot multiply it. The correct shape is \(2\times3\): two rows for the two codomain coordinates and three columns for the three domain coordinates.

For example, consider the matrix from the second worked example. Trying to multiply it by the two-entry vector \((2,-1)^{\top}\) is not a valid correction: the matrix has three columns, while that vector has only two entries. The attempted row calculations would require three terms, such as \(1(2)+0(-1)+2x_3\), but \(x_3\) has not been specified. To apply this representation, use a three-entry domain coordinate vector, such as \((2,-1,3)^{\top}\); the resulting output then has two entries. Always check matrix columns against input length before performing any arithmetic.

A reliable check is to write the dimensions next to the map before constructing or using its representation:

1
Count domain coordinates.
If \(\dim V=n\), the input coordinate vector has \(n\) entries, so the representing matrix needs \(n\) columns.
2
Count codomain coordinates.
If \(\dim W=m\), the output coordinate vector has \(m\) entries, so the representing matrix needs \(m\) rows.
3
Check the product.
An \(m\times n\) matrix times an \(n\)-entry column is defined and produces an \(m\)-entry column.

This check is useful before doing any row-by-row computation. It catches a reversed shape, an input written with the wrong number of coordinates, or a claimed output in coordinates from the wrong codomain basis. It also applies regardless of whether the bases are standard or nonstandard: the lengths come from the numbers of basis vectors, not from the appearance of the vectors themselves.

Check Your Understanding

For each question, identify the domain and codomain dimensions before deciding the matrix shape.

  1. If \(T:V\to W\), \(\dim V=5\), and \(\dim W=2\), what is the shape of \([T]_{\mathcal{C}\leftarrow\mathcal{B}}\), and how many entries does each coordinate vector have?
  2. A representing matrix has shape \(4\times3\). What must the dimensions of its domain and codomain be?
  3. Can a \(2\times4\) matrix multiply a four-entry column vector? What is the length of the result?
  4. A map has a two-dimensional domain and a four-dimensional codomain. Is its representation square or rectangular, and how many columns does it have?
  5. Explain why knowing that a representing matrix is square does not by itself show that the represented map is one-to-one or onto.

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