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}\).
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\).
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\)
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}\):
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
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:
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:
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
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
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.
- 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.
- 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})\).
- 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}\).
- Explain why equality of the \(i\)th coordinates for every \(i\) proves equality of the two vectors.
- 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.