Each Product Entry Pairs a Row with a Column
Matrix multiplication can be carried out as a collection of small scalar calculations. To find one entry of a product, take a row from the first matrix and a column from the second, multiply their entries in corresponding positions, and add the products. Repeating this for each output position fills the product matrix. The main practical challenge is keeping track of which row and column belong to each entry.
Throughout this tutorial, the matrices have real entries. Suppose \(\mathbf{A}\) has \(m\) rows and \(n\) columns, and \(\mathbf{B}\) has \(n\) rows and \(p\) columns. The shared number \(n\) means that a row of \(\mathbf{A}\) and a column of \(\mathbf{B}\) have the same length, so their entries can be paired. The product \(\mathbf{A}\mathbf{B}\) then has \(m\) rows and \(p\) columns.
The indices provide a useful tracking system. The first index \(i\) chooses a row of \(\mathbf{A}\), and the second index \(j\) chooses a column of \(\mathbf{B}\). The index \(k\) runs through the positions within that row and column. For example, to calculate \(c_{23}\), use row 2 of \(\mathbf{A}\) and column 3 of \(\mathbf{B}\), pairing their first entries, then their second entries, and continuing to the end.
It is often helpful to write the matching row and column beside the calculation before multiplying. That makes it less likely that a row is accidentally paired with another row, or that an entry is placed in the wrong position. The result’s size is also a quick organizational check: the number of output rows comes from \(\mathbf{A}\), while the number of output columns comes from \(\mathbf{B}\).
Why the Row-Column Procedure Gives the Product
Proof. By the entry formula for matrix multiplication, the entry in position \((i,j)\) of the product is the sum \(\sum_{k=1}^{n}a_{ik}b_{kj}\). For a fixed \(i\), the numbers \(a_{i1},\ldots,a_{in}\) are exactly the entries in row \(i\) of \(\mathbf{A}\). For a fixed \(j\), the numbers \(b_{1j},\ldots,b_{nj}\) are exactly the entries in column \(j\) of \(\mathbf{B}\). Thus the sum multiplies corresponding entries of that row and column and adds the results. The index \(i\) ranges over the \(m\) rows of \(\mathbf{A}\), and \(j\) ranges over the \(p\) columns of \(\mathbf{B}\). There is therefore one calculated entry for each of \(m\) row choices and \(p\) column choices, giving an \(m\times p\) matrix. \(\square\)
This proposition justifies the calculation routine: choose an output position, identify its row and column, compute the corresponding sum, and place the answer in that position. If the number of columns of \(\mathbf{A}\) does not equal the number of rows of \(\mathbf{B}\), the entries cannot be paired all the way across, and the product is not defined.
Worked Products, Entry by Entry
Worked Example: A \(2\times3\) Matrix Times a \(3\times2\) Matrix
Calculate \(\mathbf{A}\mathbf{B}\), where
The inner dimensions are both \(3\), so the product is defined. Its size is \(2\times2\): two rows from \(\mathbf{A}\) and two columns from \(\mathbf{B}\). Calculate its four entries separately.
For \(c_{11}\), pair row 1 of \(\mathbf{A}\), \((1,2,-1)\), with column 1 of \(\mathbf{B}\), \((2,-1,3)^{\top}\):
For \(c_{12}\), pair row 1 with column 2, \((1,0,2)^{\top}\):
For \(c_{21}\), pair row 2, \((0,3,4)\), with column 1:
For \(c_{22}\), pair row 2 with column 2:
Place each value in its indexed position:
Check: The top row comes from the two pairings with row 1: they give \(-3\) and \(-1\). The bottom row comes from the pairings with row 2: they give \(9\) and \(8\). These are exactly the entries in the displayed \(2\times2\) answer, in the positions specified by their indices.
Worked Example: A \(3\times2\) Matrix Times a \(2\times3\) Matrix
Calculate the product below, keeping track of the three output columns as well as the three output rows.
The inner dimensions are both \(2\). The product therefore exists and has size \(3\times3\). For row 1 of \(\mathbf{A}\), the three column pairings are
For row 2 of \(\mathbf{A}\), pair \((0,3)\) with each column of \(\mathbf{B}\):
For row 3, pair \((1,4)\) with each column:
Putting the nine calculated entries in their positions gives
Check: The three calculations using row 1 give the first output row \((4,3,-3)\); those using row 2 give \((-6,3,9)\); and those using row 3 give \((-7,6,12)\). The result has three rows from \(\mathbf{A}\) and three columns from \(\mathbf{B}\), as required. In particular, the position \(c_{32}\) uses row 3 and column 2, producing \(6\), not an entry from either the second row or the third column.
Worked Example: A Matrix Times a Column
A column matrix has one column, so the product has one output column. Calculate the product of
The number of columns in \(\mathbf{A}\) and the number of rows in \(\mathbf{b}\) are both \(3\). The result has size \(3\times1\). There is only one column to pair with each row:
Thus
Check: Repeating the pairings row by row gives \(3-2=1\), \(-6+6-1=-1\), and \(12-2=10\). Each value appears in the only column of the result, and its row matches the row used in the calculation.
A Reliable Routine and a Common Error
For a small product, use the following routine. It keeps the dimension check separate from the arithmetic, then gives each output entry a definite row and column.
For an \(m\times n\) matrix times an \(r\times p\) matrix, confirm that \(n=r\). If they match, the product will be \(m\times p\).
For position \((i,j)\), select row \(i\) of the first matrix and column \(j\) of the second.
Start with the first pair, continue through every position in the row and column, and add all the products.
Write the scalar in position \((i,j)\), then confirm the completed matrix has \(m\) rows and \(p\) columns and that each entry came from its assigned pairing.
A common mistake is to use a row of the second matrix where a column is required. For example, in the first worked example, the entry \(c_{12}\) must use row 1 of \(\mathbf{A}\), \((1,2,-1)\), and column 2 of \(\mathbf{B}\), \((1,0,2)^{\top}\). A wrong calculation might take row 2 of \(\mathbf{B}\), \((-1,0)\), and attempt \(1(-1)+2(0)\). This is not the correct pairing: that row has length \(2\), while row 1 of \(\mathbf{A}\) has length \(3\), and it is not column 2 of \(\mathbf{B}\). The correction is to read vertically down column 2 and calculate \(1(1)+2(0)+(-1)(2)=-1\).
Another useful check is to pause before doing arithmetic and name both objects aloud: “row \(i\), column \(j\).” A correct total formed from the wrong pair is still the wrong matrix entry. Writing the index under each calculation, such as \(c_{23}\), helps keep the scalar calculation connected to the output position.
Check Your Understanding
For each product, first state whether it is defined and what size the result would have. Then calculate the entries by row-column pairing.
- Calculate \(\begin{bmatrix}1&-2\\3&0\end{bmatrix}\begin{bmatrix}2&1\\-1&4\end{bmatrix}\). Show all four scalar calculations.
- For \(\mathbf{A}=\begin{bmatrix}2&1&0\\-1&3&2\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}1\\-2\\4\end{bmatrix}\), calculate \(\mathbf{A}\mathbf{B}\) and identify the row used for each output entry.
- Can a \(2\times3\) matrix be multiplied by a \(2\times2\) matrix in that order? Explain using the dimensions being paired.
- If a product is formed from a \(4\times2\) matrix and a \(2\times5\) matrix, how many scalar entries must be calculated, and what is the size of the result?
- Describe the row and column used to calculate entry \(c_{31}\) of a product \(\mathbf{A}\mathbf{B}\).