Tutorials › Linear Algebra › Computing Matrix Transformations

Linear Transformations of R^n · Tutorial 188 of 1000

Computing Matrix Transformations

Practice computing matrix transformations one output coordinate at a time and interpreting how the matrix size determines the input and output spaces.

Intermediate 9 min read

What You'll Learn

  • Match the number of matrix columns to the input-vector dimension.
  • Compute each output coordinate as a row-by-column dot product.
  • Interpret the rows of a matrix as formulas for the output coordinates.
  • Evaluate transformations from \(\mathbb{R}^2\) to \(\mathbb{R}^3\) and from \(\mathbb{R}^3\) to \(\mathbb{R}^2\).
  • Check a computed output by substituting it into the coordinate equations.

From an Input Column to an Output Column

A matrix transformation turns an input vector into an output vector by multiplying the matrix by the input column. The entries of the input specify the coordinates being combined, while each row of the matrix determines one coordinate of the output. Keeping track of which row produces which output coordinate makes the calculation easier to organize and helps catch dimension and arithmetic errors.

Work over \(\mathbb{R}\). Let \(\mathbf{A}\) be an \(m\times n\) matrix, meaning that it has \(m\) rows and \(n\) columns. The matrix defines a function \(T_{\mathbf{A}}:\mathbb{R}^n\to\mathbb{R}^m\) by \(T_{\mathbf{A}}(\mathbf{x})=\mathbf{A}\mathbf{x}\). The input must have \(n\) coordinates so that the product is defined, and the output has \(m\) coordinates because there is one output coordinate for each row of \(\mathbf{A}\).

Definition: For \(\mathbf{A}=(a_{ij})\in\mathbb{R}^{m\times n}\) and \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\in\mathbb{R}^n\), the matrix transformation is \(T_{\mathbf{A}}(\mathbf{x})=\mathbf{A}\mathbf{x}\). Its \(i\)th output coordinate is the dot product of row \(i\) of \(\mathbf{A}\) with \(\mathbf{x}\): \(y_i=\sum_{j=1}^{n}a_{ij}x_j\), for \(i=1,\dots,m\).

In practical terms, take the first row of \(\mathbf{A}\), multiply its entries by the corresponding entries of \(\mathbf{x}\), and add those products to get \(y_1\). Repeat with the second row to get \(y_2\), continuing until every row has contributed one coordinate. The result is a column in \(\mathbb{R}^m\). Do not multiply a row of \(\mathbf{A}\) by another row, or pair the input with the columns to compute individual output coordinates.

Theorem (Row-by-column formula): If \(\mathbf{A}=(a_{ij})\in\mathbb{R}^{m\times n}\) and \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\in\mathbb{R}^n\), then \(\mathbf{A}\mathbf{x}=(\sum_{j=1}^{n}a_{1j}x_j,\dots,\sum_{j=1}^{n}a_{mj}x_j)^{\top}\in\mathbb{R}^m\).

Proof. By the definition of matrix multiplication, the entry in row \(i\) of the product \(\mathbf{A}\mathbf{x}\) is the sum of the products of the entries in row \(i\) of \(\mathbf{A}\) with the entries in the column \(\mathbf{x}\). That entry is \(\sum_{j=1}^{n}a_{ij}x_j\). This holds for each \(i=1,\dots,m\), so the product has the stated coordinates and has \(m\) entries. Therefore it belongs to \(\mathbb{R}^m\). \(\square\)

This formula also explains how to interpret a computed output: each coordinate is a specific weighted sum of the input coordinates. The weights are the entries in one row. Reading the rows from top to bottom gives the output coordinates in order.

Output Coordinates as Scalar Equations

Sometimes it is useful to write the product as a list of equations, especially when checking whether a proposed output is correct. For an input with coordinates \(x_1,\dots,x_n\), the first row gives the first output coordinate, the second row gives the second output coordinate, and so on. An equality of two output columns holds exactly when the corresponding coordinates agree one by one.

Proposition: For \(\mathbf{A}=(a_{ij})\in\mathbb{R}^{m\times n}\), \(\mathbf{x}\in\mathbb{R}^n\), and \(\mathbf{y}=(y_1,\dots,y_m)^{\top}\in\mathbb{R}^m\), \(\mathbf{A}\mathbf{x}=\mathbf{y}\) if and only if \(\sum_{j=1}^{n}a_{ij}x_j=y_i\) for every \(i=1,\dots,m\).

Proof. Suppose first that \(\mathbf{A}\mathbf{x}=\mathbf{y}\). By the row-by-column formula, the \(i\)th coordinate of \(\mathbf{A}\mathbf{x}\) is \(\sum_{j=1}^{n}a_{ij}x_j\). Equality of the two columns means equality of their \(i\)th coordinates, so \(\sum_{j=1}^{n}a_{ij}x_j=y_i\) for every \(i\). Conversely, suppose those \(m\) scalar equalities hold. The row-by-column formula says that the coordinates of \(\mathbf{A}\mathbf{x}\) are precisely their left sides. Each coordinate therefore equals the corresponding coordinate of \(\mathbf{y}\), which gives \(\mathbf{A}\mathbf{x}=\mathbf{y}\). \(\square\)

Worked Examples in Two and Three Coordinates

Worked Example: A Transformation from R² to R²

Let \(T_{\mathbf{A}}:\mathbb{R}^2\to\mathbb{R}^2\) be defined by \(\mathbf{A}=\begin{bmatrix}2&-1\\3&4\end{bmatrix}\). Compute \(T_{\mathbf{A}}(\mathbf{x})\) for \(\mathbf{x}=\begin{bmatrix}5\\-2\end{bmatrix}\), and explain the output coordinates.

The matrix has two columns, matching the two entries of the input, and two rows, so the output has two coordinates. The first row gives \(2(5)+(-1)(-2)=10+2=12\). The second row gives \(3(5)+4(-2)=15-8=7\). Thus

$$ T_{\mathbf{A}}(\mathbf{x}) = \begin{bmatrix}2&-1\\3&4\end{bmatrix} \begin{bmatrix}5\\-2\end{bmatrix} = \begin{bmatrix}2(5)+(-1)(-2)\\3(5)+4(-2)\end{bmatrix} = \begin{bmatrix}12\\7\end{bmatrix}. $$

The output’s first coordinate is \(12\), obtained from the first row; its second coordinate is \(7\), obtained from the second row. Check: the row formulas give \(2(5)-(-2)=12\) and \(3(5)+4(-2)=7\), matching both entries of the output column.

Worked Example: A Transformation from R² to R³

Let \(T_{\mathbf{B}}:\mathbb{R}^2\to\mathbb{R}^3\) be defined by \(\mathbf{B}=\begin{bmatrix}1&2\\-2&1\\3&-1\end{bmatrix}\). Compute the image of \(\mathbf{u}=\begin{bmatrix}2\\-1\end{bmatrix}\).

The matrix has two columns, so an input in \(\mathbb{R}^2\) is the correct size. It has three rows, so its output has three coordinates. Calculate those coordinates row by row:

$$ \begin{aligned} y_1&=1(2)+2(-1)=2-2=0,\\ y_2&=(-2)(2)+1(-1)=-4-1=-5,\\ y_3&=3(2)+(-1)(-1)=6+1=7. \end{aligned} $$

Therefore \(T_{\mathbf{B}}(\mathbf{u})=\begin{bmatrix}0\\-5\\7\end{bmatrix}\). This output lies in \(\mathbb{R}^3\), even though the input lies in \(\mathbb{R}^2\): the number of output coordinates is determined by the number of rows, not by the number of input coordinates.

Check: using the displayed row equations, the first coordinate is \(0\), the second is \(-5\), and the third is \(7\). Hence \(\mathbf{B}\mathbf{u}=\begin{bmatrix}0\\-5\\7\end{bmatrix}\), as calculated.

Worked Example: A Transformation from R³ to R²

Let \(T_{\mathbf{C}}:\mathbb{R}^3\to\mathbb{R}^2\) be defined by \(\mathbf{C}=\begin{bmatrix}1&0&-2\\2&-1&3\end{bmatrix}\). Evaluate it at \(\mathbf{v}=\begin{bmatrix}1\\4\\-2\end{bmatrix}\), and describe how each output coordinate is formed.

The three columns match the three input coordinates. There are two rows, so there will be two output coordinates. The first row gives \(1(1)+0(4)+(-2)(-2)=1+0+4=5\). The second row gives \(2(1)+(-1)(4)+3(-2)=2-4-6=-8\). Thus

$$ T_{\mathbf{C}}(\mathbf{v}) = \begin{bmatrix} 1(1)+0(4)+(-2)(-2)\\ 2(1)+(-1)(4)+3(-2) \end{bmatrix} = \begin{bmatrix}5\\-8\end{bmatrix}. $$

The first output coordinate combines all three input coordinates using the first row’s weights \(1,0,-2\); the second combines them using \(2,-1,3\). Check: \(1+0+4=5\) and \(2-4-6=-8\), so each row formula reproduces the corresponding coordinate of the product.

A Reliable Calculation Routine

For a new matrix transformation, use the following sequence. It keeps the dimensions visible and makes the source of every output entry explicit.

1
Check the input size.
If \(\mathbf{A}\) has \(n\) columns, the input must have \(n\) entries. A mismatch means that \(\mathbf{A}\mathbf{x}\) is not defined.
2
Assign one output coordinate to each row.
An \(m\times n\) matrix produces an output in \(\mathbb{R}^m\), with \(m\) coordinates.
3
Calculate row by row.
Multiply corresponding entries in the current row and input column, then add the products. Repeat for every row.
4
Check the result.
Substitute the input coordinates into each row formula and confirm that each value matches the output coordinate in the same position.

The routine is justified by the definition of matrix multiplication: its \(i\)th entry is the sum of the products from row \(i\) and the input column. Therefore the row-by-row calculation does not approximate the transformation or change its order; it computes each coordinate of the product as defined.

Common Pitfall: Confusing Rows and Columns

A frequent error is to use the entries in a column of the matrix as though they formed one output coordinate. For example, with \(\mathbf{B}=\begin{bmatrix}1&2\\-2&1\\3&-1\end{bmatrix}\) and \(\mathbf{u}=\begin{bmatrix}2\\-1\end{bmatrix}\), the incorrect calculation \(1(2)+(-2)(-1)+3(2)=10\) combines the first entries of the input with the first column of \(\mathbf{B}\). That is not the row-by-column rule, and \(10\) is not an output coordinate here.

The correction is to form one sum from each row, using every entry of that row and the corresponding input entry. In this case, the three sums are \(1(2)+2(-1)=0\), \((-2)(2)+1(-1)=-5\), and \(3(2)+(-1)(-1)=7\). The correct result is \(\begin{bmatrix}0\\-5\\7\end{bmatrix}\). The two input coordinates combine to produce three output coordinates because the matrix has three rows.

Also avoid a dimension error: multiplying this \(3\times2\) matrix by a vector with three entries is not defined. It is the number of columns that must match the input length; the number of rows determines the output length.

Why Coordinate-by-Coordinate Computation Matters

The matrix product turns a single vector equation into a list of scalar calculations. That makes a transformation concrete: its input coordinates are the values being combined, and each row specifies exactly how one output coordinate is formed. This viewpoint applies whether the output has fewer coordinates than the input, the same number, or more.

When checking work, confirm three things: the input has as many entries as the matrix has columns, the output has as many entries as the matrix has rows, and each output entry was calculated from the corresponding row. These checks address different possible errors; getting the right output length alone does not guarantee that the arithmetic is correct.

Check Your Understanding

For each calculation, keep the input and output dimensions explicit and show the row sums.

  1. Let \(\mathbf{A}=\begin{bmatrix}3&1\\-1&2\end{bmatrix}\). Compute \(T_{\mathbf{A}}\left(\begin{bmatrix}2\\-3\end{bmatrix}\right)\).
  2. For \(\mathbf{B}=\begin{bmatrix}1&-1\\2&0\\-3&4\end{bmatrix}\), state the domain and codomain of \(T_{\mathbf{B}}\), then evaluate it at \(\begin{bmatrix}1\\2\end{bmatrix}\).
  3. For \(\mathbf{C}=\begin{bmatrix}2&1&0\\-1&3&2\end{bmatrix}\), evaluate \(T_{\mathbf{C}}\) at \(\begin{bmatrix}1\\-2\\3\end{bmatrix}\). How many coordinates does the output have?
  4. Explain why a \(4\times2\) matrix can be multiplied by a vector in \(\mathbb{R}^2\), and state the space containing the product.
  5. For a general \(m\times n\) matrix \(\mathbf{A}\), write the formula for the \(i\)th coordinate of \(\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