One Row, One Output Coordinate
A matrix-vector product can be calculated one coordinate at a time. The row-by-row method pairs the entries of a row with the entries of the vector in order, multiplies each pair, and adds the results. Each row gives one scalar, and those scalars, in row order, form the product vector. This makes it important to keep track of the matrix’s number of rows and columns as well as the order of every entry.
Throughout, scalars are real. Let \(\mathbf{A}\) be an \(m\times n\) matrix and let \(\mathbf{x}\) be a column vector in \(\mathbb{R}^n\). Write the entries of \(\mathbf{A}\) as \(a_{ij}\), where \(i\) specifies a row and \(j\) specifies a column, and write the entries of \(\mathbf{x}\) as \(x_1,\dots,x_n\). The number of entries in \(\mathbf{x}\) matches the number of entries in each row of \(\mathbf{A}\), so each row can be paired with the whole vector.
For example, if row \(i\) is \((a_{i1},a_{i2},\dots,a_{in})\), its contribution is the single number \(a_{i1}x_1+a_{i2}x_2+\cdots+a_{in}x_n\). The first row produces the first output entry, the second row produces the second, and so on. Thus an \(m\times n\) matrix times a vector with \(n\) entries produces a vector with \(m\) entries. The \(n\) entries tell us how many products are added for each row; the \(m\) rows tell us how many output entries there are.
Proof. By the definition of matrix multiplication, the entry in row \(i\) of the product is obtained by multiplying each entry in row \(i\) of \(\mathbf{A}\) by the corresponding entry of the column vector \(\mathbf{x}\), then summing over the \(n\) columns. That entry is therefore \(\sum_{j=1}^{n}a_{ij}x_j=a_{i1}x_1+\cdots+a_{in}x_n\). Since the product has one such entry for each of the \(m\) rows of \(\mathbf{A}\), it has \(m\) coordinates. \(\square\)
Calculating the Product in Order
A reliable calculation follows the same sequence for each row: write down the row’s products, evaluate them, and add. Keep the row and vector entries in their original order. The product is written as a column vector, with the row results appearing from top to bottom. The examples below include the dimensions so the number of input and output entries can be checked as part of the calculation.
Worked Example: A Two-by-Three Matrix
Calculate \(\mathbf{A}\mathbf{x}\) for the \(2\times3\) matrix and three-entry vector below.
The first row of \(\mathbf{A}\) gives the first coordinate. Pair its entries \(2,-1,3\), in order, with the vector entries \(2,-1,3\):
The second row gives the second coordinate. Pair \(0,4,1\) with the same vector entries:
There are two rows, so the product has two coordinates. The calculation gives
Check: Repeating the row dot products gives \(2(2)+(-1)(-1)+3(3)=14\) and \(0(2)+4(-1)+1(3)=-1\), exactly the two entries of the displayed product. The input has three entries to match the three columns; the output has two entries to match the two rows.
Worked Example: Three Rows and Two Entries
Here the vector has two entries, so each row of the \(3\times2\) matrix gives a sum of two products.
Use the first row for the first coordinate, the second row for the second coordinate, and the third row for the third coordinate:
Since there are three rows, collect the three results in a three-entry column:
Check: The first output entry is \(1(-2)+5(3)=13\); the second is \((-3)(-2)+2(3)=12\); and the third is \(4(-2)+0(3)=-8\). Each entry agrees with the dot product of its corresponding row and \(\mathbf{x}\).
What a Zero Row Does
A row filled with zeros produces a zero output entry, whatever the entries of the input vector are. More generally, if two matrices of the same size have the same row at a given position, multiplying them by the same compatible vector gives the same output at that position. These facts follow directly from the row formula; they are useful checks when carrying out a calculation.
Proof. If row \(i\) of \(\mathbf{A}\) is zero, then \(a_{ij}=0\) for every \(j=1,\dots,n\). The row formula gives the \(i\)th coordinate as \(\sum_{j=1}^{n}a_{ij}x_j=\sum_{j=1}^{n}0x_j=0\). Now suppose row \(i\) of \(\mathbf{A}\) equals row \(i\) of \(\mathbf{B}\). Then \(a_{ij}=b_{ij}\) for every \(j\). Applying the row formula to each product gives \(\sum_{j=1}^{n}a_{ij}x_j=\sum_{j=1}^{n}b_{ij}x_j\), so their \(i\)th output coordinates agree. \(\square\)
Worked Example: A Zero Row and a Negative Entry
Calculate the product below and identify which output entry is forced by the zero row.
The first row gives
The second row is zero, so its dot product with the vector is \(0(1)+0(-2)+0(0)=0\). The third row gives
In row order, the product is therefore
Check: The three row dot products are \(-3\), \(0\), and \(-4\), respectively. In particular, the middle output coordinate is zero because every entry of the middle row is zero.
Keeping Dimensions and Entry Order Straight
Before multiplying, record the matrix size and the number of vector entries. For an \(m\times n\) matrix and an \(n\)-entry column vector, each row has exactly \(n\) entries to pair with the vector, and there are \(m\) row calculations. This is a practical way to catch a mismatch: an input entry must be available for each column position, and the final column must contain one result per row.
The row index and column index answer different questions. In \(a_{ij}\), \(i\) selects which output coordinate is being calculated, because it selects the row. The index \(j\) selects which pair of entries is multiplied within that row. For instance, \(a_{23}\) is in row 2 and column 3: it contributes to the second output coordinate and is multiplied by \(x_3\). Keeping these roles separate prevents entries from being assigned to the wrong coordinate.
The order within each row matters too. A row \((a_{i1},a_{i2},a_{i3})\) pairs with \((x_1,x_2,x_3)^{\top}\) as \(a_{i1}x_1+a_{i2}x_2+a_{i3}x_3\). Reversing the vector entries changes which values are multiplied together, and can change the answer even when all the same numbers still appear in the calculation.
Common Mistake: Reversing the Vector Entries
Consider the row \((1,4,-2)\) and the vector \(\mathbf{x}=(3,-1,2)^{\top}\). A tempting but incorrect calculation reverses the vector entries while pairing them with the row:
This does not use the entries in corresponding positions: the first row entry must be paired with \(x_1=3\), not with \(x_3=2\). The correct dot product is
Thus the row produces \(-5\), not \(-8\). A useful correction is to write the entries under one another before multiplying: first row entry with first vector entry, second with second, and third with third. Also preserve the output’s column shape: the scalar found from one row is one coordinate, and all row results are placed vertically in their original row order.
When checking an answer, do not merely count its entries. Recalculate each one from its row and compare the resulting scalar with the corresponding coordinate of the proposed product. This checks both the arithmetic and the pairing order. If a row is zero, its output coordinate must be zero; if two rows are identical, their output coordinates must agree. These are quick consistency checks, not replacements for calculating every row.
Check Your Understanding
For each product, show the row dot products in order and write the answer as a column vector.
- Calculate \(\begin{bmatrix}3&-2\\1&4\end{bmatrix}\begin{bmatrix}2\\-1\end{bmatrix}\). How many output coordinates should there be?
- Calculate \(\begin{bmatrix}0&5&1\\-2&1&3\end{bmatrix}\begin{bmatrix}1\\2\\-1\end{bmatrix}\). Which row determines the second output coordinate?
- A \(4\times2\) matrix multiplies a vector in \(\mathbb{R}^2\). How many terms are added for each output coordinate, and how many output coordinates result?
- For the row \((2,-1,3)\) and vector \((1,4,-2)^{\top}\), calculate the correct dot product. State the entry pairings in order.
- Explain why a zero row in a matrix always produces a zero in the corresponding coordinate of its product with any compatible vector.