Tutorials › Linear Algebra › Proving the Row and Column Formulas for Ax Agree

Vectors and Linear Combinations · Tutorial 124 of 1000

Proving the Row and Column Formulas for Ax Agree

Learn why the row and column calculations of a matrix-vector product agree, and verify the identity with exact arithmetic.

Beginner 9 min read

What You'll Learn

  • Identify the rows and columns used in the two formulas for a matrix-vector product
  • Expand an individual coordinate of the product using matrix entries
  • Prove that the row and column calculations produce the same vector
  • Compute the product in both ways and check the result
  • Spot and correct a common row-versus-column calculation error

Two Ways to Read the Same Product

A matrix-vector product can be calculated by taking dot products with the rows of the matrix, or by combining the columns using the entries of the vector as coefficients. These procedures may look different: one produces coordinates separately, while the other adds scaled column vectors. The agreement is not a coincidence. Both procedures compute the same finite sums of matrix entries and vector entries, grouped in different ways.

Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\), and let \(\mathbf{x}\in\mathbb{R}^n\). Write the entries of \(\mathbf{A}\) as \(a_{ij}\), where \(i\) identifies a row and \(j\) identifies a column. Write the entries of \(\mathbf{x}\) as \(x_1,\dots,x_n\). Denote the \(i\)th row of \(\mathbf{A}\) by \((a_{i1},\dots,a_{in})\), and its \(j\)th column by \(\mathbf{a}_j\in\mathbb{R}^m\). All vectors, including \(\mathbf{x}\) and the columns, are columns; a row is displayed as a row when taking its dot product with \(\mathbf{x}\).

Definition: The row formula for \(\mathbf{A}\mathbf{x}\) gives its \(i\)th coordinate as the dot product of row \(i\) of \(\mathbf{A}\) with \(\mathbf{x}\): \( (\mathbf{A}\mathbf{x})_i=\sum_{j=1}^{n}a_{ij}x_j\). The column formula writes the product as a linear combination of the columns of \(\mathbf{A}\): \(\mathbf{A}\mathbf{x}=\sum_{j=1}^{n}x_j\mathbf{a}_j\).

The row formula gives \(m\) scalar coordinates, one for each row. The column formula gives one vector in \(\mathbb{R}^m\), formed from the \(n\) columns. A coefficient \(x_j\) multiplies column \(j\) in the column formula; the same \(x_j\) multiplies entry \(a_{ij}\) in every row formula. The proof below makes that correspondence precise, one coordinate at a time.

Expanding a Coordinate

First consider the \(i\)th coordinate of the column combination. Each column \(\mathbf{a}_j\) has \(i\)th coordinate \(a_{ij}\). Scaling that column by \(x_j\) makes its \(i\)th coordinate \(x_ja_{ij}\). Adding all the scaled columns therefore adds those \(i\)th coordinates. The row formula lists exactly the same terms, written in the order \(a_{i1}x_1,\dots,a_{in}x_n\).

Theorem (Coordinate expansion): Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\) have columns \(\mathbf{a}_1,\dots,\mathbf{a}_n\), and let \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\in\mathbb{R}^n\). For each \(i\in\{1,\dots,m\}\), the \(i\)th coordinate of \(\sum_{j=1}^{n}x_j\mathbf{a}_j\) is \(\sum_{j=1}^{n}a_{ij}x_j\).

Proof. Fix any \(i\in\{1,\dots,m\}\). The \(i\)th coordinate of the sum of vectors is the sum of their \(i\)th coordinates. The \(i\)th coordinate of \(\mathbf{a}_j\) is \(a_{ij}\), so scaling \(\mathbf{a}_j\) by \(x_j\) gives \(i\)th coordinate \(x_ja_{ij}\). Thus the coordinate of the whole sum is \(\sum_{j=1}^{n}x_ja_{ij}\). Since real multiplication is commutative, \(x_ja_{ij}=a_{ij}x_j\) for each \(j\), and the coordinate is \(\sum_{j=1}^{n}a_{ij}x_j\), as claimed. The argument holds for every permitted \(i\). \(\square\)

Corollary (Agreement of the row and column formulas): For \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{x}\in\mathbb{R}^n\), the vector obtained by taking the row dot products is equal to the column combination \(\sum_{j=1}^{n}x_j\mathbf{a}_j\).

Proof. Let \(\mathbf{y}\) be the vector whose \(i\)th coordinate is the row dot product \(\sum_{j=1}^{n}a_{ij}x_j\). By the coordinate expansion theorem, the \(i\)th coordinate of \(\sum_{j=1}^{n}x_j\mathbf{a}_j\) has exactly that same value for every \(i\in\{1,\dots,m\}\). Two vectors in \(\mathbb{R}^m\) are equal when all corresponding coordinates are equal. Hence \(\mathbf{y}=\sum_{j=1}^{n}x_j\mathbf{a}_j\), proving that the two formulas agree. \(\square\)

Worked Examples in Both Forms

Worked Example: A Two-Row, Three-Column Matrix

Compute the product in both ways for \(\mathbf{A}=\begin{bmatrix}1&-2&3\\0&4&-1\end{bmatrix}\) and \(\mathbf{x}=\begin{bmatrix}2\\-1\\3\end{bmatrix}\).

Using the rows, the first coordinate is the dot product of the first row with \(\mathbf{x}\), and the second coordinate is the dot product of the second row with \(\mathbf{x}\):

$$ \begin{aligned} (\mathbf{A}\mathbf{x})_1&=1(2)+(-2)(-1)+3(3)=2+2+9=13,\\ (\mathbf{A}\mathbf{x})_2&=0(2)+4(-1)+(-1)(3)=0-4-3=-7. \end{aligned} $$

Thus the row calculation gives \(\begin{bmatrix}13\\-7\end{bmatrix}\). For the column calculation, the columns are \(\mathbf{a}_1=\begin{bmatrix}1\\0\end{bmatrix}\), \(\mathbf{a}_2=\begin{bmatrix}-2\\4\end{bmatrix}\), and \(\mathbf{a}_3=\begin{bmatrix}3\\-1\end{bmatrix}\). The entries of \(\mathbf{x}\), in order, are \(2,-1,3\), so

$$ \begin{aligned} 2\mathbf{a}_1+(-1)\mathbf{a}_2+3\mathbf{a}_3 &=\begin{bmatrix}2\\0\end{bmatrix} +\begin{bmatrix}2\\-4\end{bmatrix} +\begin{bmatrix}9\\-3\end{bmatrix}\\ &=\begin{bmatrix}2+2+9\\0-4-3\end{bmatrix} =\begin{bmatrix}13\\-7\end{bmatrix}. \end{aligned} $$

Check: The two calculations give the same vector. Substituting into the row formulas confirms \(13=1(2)+(-2)(-1)+3(3)\) and \(-7=0(2)+4(-1)+(-1)(3)\).

Worked Example: A Three-Row, Two-Column Matrix

Compute both formulas for \(\mathbf{B}=\begin{bmatrix}2&1\\-1&3\\0&-2\end{bmatrix}\) and \(\mathbf{z}=\begin{bmatrix}4\\-2\end{bmatrix}\).

With the rows, calculate each of the three coordinates separately:

$$ \begin{aligned} (\mathbf{B}\mathbf{z})_1&=2(4)+1(-2)=8-2=6,\\ (\mathbf{B}\mathbf{z})_2&=(-1)(4)+3(-2)=-4-6=-10,\\ (\mathbf{B}\mathbf{z})_3&=0(4)+(-2)(-2)=0+4=4. \end{aligned} $$

The row calculation gives \(\begin{bmatrix}6\\-10\\4\end{bmatrix}\). The two columns of \(\mathbf{B}\) are \(\mathbf{b}_1=\begin{bmatrix}2\\-1\\0\end{bmatrix}\) and \(\mathbf{b}_2=\begin{bmatrix}1\\3\\-2\end{bmatrix}\). The column formula uses the entries \(4\) and \(-2\) of \(\mathbf{z}\) as coefficients:

$$ \begin{aligned} 4\mathbf{b}_1+(-2)\mathbf{b}_2 &=\begin{bmatrix}8\\-4\\0\end{bmatrix} +\begin{bmatrix}-2\\-6\\4\end{bmatrix}\\ &=\begin{bmatrix}8-2\\-4-6\\0+4\end{bmatrix} =\begin{bmatrix}6\\-10\\4\end{bmatrix}. \end{aligned} $$

Check: The first coordinate is \(6=2(4)+1(-2)\), the second is \(-10=(-1)(4)+3(-2)\), and the third is \(4=0(4)+(-2)(-2)\). Each coordinate agrees with the corresponding row calculation.

Worked Example: Three Rows and Three Columns

For \(\mathbf{C}=\begin{bmatrix}1&0&-2\\3&2&1\\-1&4&0\end{bmatrix}\) and \(\mathbf{w}=\begin{bmatrix}-1\\2\\3\end{bmatrix}\), find \(\mathbf{C}\mathbf{w}\) by rows and by columns.

The row dot products are

$$ \begin{aligned} (\mathbf{C}\mathbf{w})_1&=1(-1)+0(2)+(-2)(3)=-1+0-6=-7,\\ (\mathbf{C}\mathbf{w})_2&=3(-1)+2(2)+1(3)=-3+4+3=4,\\ (\mathbf{C}\mathbf{w})_3&=(-1)(-1)+4(2)+0(3)=1+8+0=9. \end{aligned} $$

Therefore the row calculation gives \(\begin{bmatrix}-7\\4\\9\end{bmatrix}\). The columns are \(\mathbf{c}_1=\begin{bmatrix}1\\3\\-1\end{bmatrix}\), \(\mathbf{c}_2=\begin{bmatrix}0\\2\\4\end{bmatrix}\), and \(\mathbf{c}_3=\begin{bmatrix}-2\\1\\0\end{bmatrix}\). Using the entries \(-1,2,3\) of \(\mathbf{w}\) as the coefficients gives

$$ \begin{aligned} (-1)\mathbf{c}_1+2\mathbf{c}_2+3\mathbf{c}_3 &=\begin{bmatrix}-1\\-3\\1\end{bmatrix} +\begin{bmatrix}0\\4\\8\end{bmatrix} +\begin{bmatrix}-6\\3\\0\end{bmatrix}\\ &=\begin{bmatrix}-1+0-6\\-3+4+3\\1+8+0\end{bmatrix} =\begin{bmatrix}-7\\4\\9\end{bmatrix}. \end{aligned} $$

Check: The column sum has coordinates \(-7,4,9\), which match the three row dot products. In particular, the coefficient \(-1\) multiplies the entire first column, giving \(\begin{bmatrix}-1\\-3\\1\end{bmatrix}\), not just its first entry.

Keeping Track of Rows, Columns, and Coefficients

The formulas agree because they organize the same contribution \(a_{ij}x_j\) in two ways. Fixing a row \(i\) and letting \(j\) vary adds the entries across that row, each weighted by the corresponding entry of \(\mathbf{x}\). Fixing a column \(j\) and letting \(i\) vary forms a whole scaled column; adding those columns gathers the contributions to all output coordinates. Thus every matrix entry is paired with the vector entry indexed by its column, regardless of which calculation is used.

This also explains why the order of the column combination matters. The coefficient of column \(j\) is \(x_j\), not \(x_i\), and columns are taken in the same order as the entries of \(\mathbf{x}\). In the row formula, by contrast, a fixed output coordinate \(i\) uses the entire \(i\)th row. The row index selects the output coordinate; the column index selects the coefficient from \(\mathbf{x}\).

When checking a calculation, write out one coordinate of each formula before shortening the arithmetic. For example, in the first worked example, the second row gives \(0(2)+4(-1)+(-1)(3)\), while the second coordinate from the column sum is \(0+(-4)+(-3)\). The terms correspond in order because they come from row 2 of columns 1, 2, and 3.

Common Mistake: Using the Wrong Row

A tempting error is to compute the first row dot product correctly and then use it again as the second coordinate. For the first example, this mistake would give \(\begin{bmatrix}13\\13\end{bmatrix}\), because it repeats \(1(2)+(-2)(-1)+3(3)=13\). But output coordinate 2 comes from row 2, not row 1: its correct calculation is \(0(2)+4(-1)+(-1)(3)=-7\). The correction is \(\mathbf{A}\mathbf{x}=\begin{bmatrix}13\\-7\end{bmatrix}\).

A related error is to pair a column with the wrong coefficient. In the first example, column 2 must be multiplied by \(x_2=-1\), so its contribution is \((-1)\begin{bmatrix}-2\\4\end{bmatrix}=\begin{bmatrix}2\\-4\end{bmatrix}\). Using \(x_1=2\) for that column would break the correspondence with the row sums. A reliable check is to label each column with its index and attach \(x_j\) to column \(j\) before adding.

Check Your Understanding

For each calculation, identify the row or column contributions before combining them.

  1. For \(\mathbf{A}=\begin{bmatrix}2&-1\\1&3\end{bmatrix}\) and \(\mathbf{x}=\begin{bmatrix}2\\-1\end{bmatrix}\), compute \(\mathbf{A}\mathbf{x}\) by both formulas.
  2. Write the row formula for coordinate 2 of a product \(\mathbf{A}\mathbf{x}\) when row 2 of \(\mathbf{A}\) is \((a_{21},a_{22},a_{23})\).
  3. If \(\mathbf{A}\) has columns \(\mathbf{a}_1,\mathbf{a}_2,\mathbf{a}_3\) and \(\mathbf{x}=\begin{bmatrix}0\\-2\\4\end{bmatrix}\), write the column formula for \(\mathbf{A}\mathbf{x}\).
  4. Explain why equality of the \(i\)th coordinates for every \(i\) proves equality of the two vectors.
  5. For \(\mathbf{B}=\begin{bmatrix}1&2\\0&-1\\3&1\end{bmatrix}\) and \(\mathbf{z}=\begin{bmatrix}-1\\2\end{bmatrix}\), calculate the third coordinate by rows and by the column combination.

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