How One Entry of a Product Is Formed
Matrix multiplication combines entries from two matrices in a particular indexed pattern. To find an entry of the product, choose a row of the first matrix and a column of the second. Multiply entries that occupy the same position within those selections, then add the products. The shared index records those paired positions; the row and column indices identify which entry of the answer is being calculated.
Let \(m,n,p\in\mathbb{N}\), let \(\mathbf{A}=(a_{ik})\in\mathbb{R}^{m\times n}\), and let \(\mathbf{B}=(b_{kj})\in\mathbb{R}^{n\times p}\). The number of columns of \(\mathbf{A}\) equals the number of rows of \(\mathbf{B}\), both \(n\), so the product \(\mathbf{A}\mathbf{B}\) is defined. It has \(m\) rows, indexed by \(i\), and \(p\) columns, indexed by \(j\). The shared index \(k\) runs from \(1\) through \(n\).
There are three indices to keep distinct. The index \(i\) selects a row in \(\mathbf{A}\); \(j\) selects a column in \(\mathbf{B}\); and \(k\) pairs entries along the shared dimension. For a fixed pair \(i,j\), the calculation uses \(n\) products, one for each \(k=1,\ldots,n\). In the term \(a_{ik}b_{kj}\), the second index of \(a_{ik}\) and the first index of \(b_{kj}\) are the matching ones.
Proof of the entry formula. By the definition of matrix multiplication, the entry in row \(i\), column \(j\) of the product is obtained by pairing the entries in row \(i\) of the first factor with the corresponding entries in column \(j\) of the second factor and adding the products. The entries of that row are \(a_{i1},a_{i2},\ldots,a_{in}\), and the entries of that column are \(b_{1j},b_{2j},\ldots,b_{nj}\). Pairing the first entries gives \(a_{i1}b_{1j}\), pairing the second gives \(a_{i2}b_{2j}\), and continuing through position \(n\) gives \(c_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots+a_{in}b_{nj}=\sum_{k=1}^{n}a_{ik}b_{kj}\). The possible values of \(i\) and \(j\) give exactly \(m\) rows and \(p\) columns. \(\square\)
The formula also tells us how to check that an entry calculation has the right shape: every product in the sum must use one entry from each matrix, and the inner indices must match. The outer indices do not have to match each other. In particular, \(i\) belongs to \(\mathbf{A}\) and \(j\) belongs to \(\mathbf{B}\); they become the row and column indices of the answer.
The Product Is Determined Entry by Entry
Proof. For every allowed pair \(i,j\), the sum \(\sum_{k=1}^{n}a_{ik}b_{kj}\) is a real number, since it is a finite sum of products of real numbers. Assign that number to position \(i,j\) of an \(m\times p\) array. This constructs a matrix with the required entries, so such a matrix exists. If \(\mathbf{C}\) and \(\mathbf{D}\) are two \(m\times p\) matrices with the required property, then for every \(i,j\), \(c_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}=d_{ij}\). Matrices of the same size are equal when all corresponding entries are equal, so \(\mathbf{C}=\mathbf{D}\). Thus the matrix exists and is unique. \(\square\)
This proposition gives a precise meaning to calculating a product entry by entry: once the factors are fixed, there is no choice about what number belongs in a particular position. The two outside indices range independently over the rows of \(\mathbf{A}\) and columns of \(\mathbf{B}\); each such pair specifies one entry.
Worked Products With Explicit Indices
Worked Example: A Product of Two \(2\times2\) Matrices
Calculate \(\mathbf{A}\mathbf{B}\), where \(\mathbf{A}=\begin{bmatrix}2&-1\\3&4\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}1&5\\-2&0\end{bmatrix}\). Both matrices have two columns or rows, respectively, so the shared index \(k\) takes the values \(1,2\). The result has two rows and two columns.
For \(c_{11}\), use row 1 of \(\mathbf{A}\) and column 1 of \(\mathbf{B}\): \(c_{11}=a_{11}b_{11}+a_{12}b_{21}=2(1)+(-1)(-2)=2+2=4\).
For \(c_{12}\), use row 1 and column 2: \(c_{12}=a_{11}b_{12}+a_{12}b_{22}=2(5)+(-1)(0)=10+0=10\).
For \(c_{21}\), use row 2 and column 1: \(c_{21}=a_{21}b_{11}+a_{22}b_{21}=3(1)+4(-2)=3-8=-5\).
For \(c_{22}\), use row 2 and column 2: \(c_{22}=a_{21}b_{12}+a_{22}b_{22}=3(5)+4(0)=15+0=15\). Therefore
Check: Reapplying the entry formula gives \(2(1)+(-1)(-2)=4\), \(2(5)+(-1)(0)=10\), \(3(1)+4(-2)=-5\), and \(3(5)+4(0)=15\). These are exactly the four displayed entries.
Worked Example: A Rectangular Product
Find the product of \(\mathbf{A}=\begin{bmatrix}1&2&-1\\0&3&4\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&1\\-1&5\\3&-2\end{bmatrix}\). The shared dimension is \(3\), so each entry is a sum of three products. The answer has two rows, from \(\mathbf{A}\), and two columns, from \(\mathbf{B}\).
First row, first column: \(c_{11}=1(2)+2(-1)+(-1)(3)=2-2-3=-3\).
First row, second column: \(c_{12}=1(1)+2(5)+(-1)(-2)=1+10+2=13\).
Second row, first column: \(c_{21}=0(2)+3(-1)+4(3)=0-3+12=9\).
Second row, second column: \(c_{22}=0(1)+3(5)+4(-2)=0+15-8=7\). Hence
Check: The four entry sums, in order, are \(2-2-3=-3\), \(1+10+2=13\), \(0-3+12=9\), and \(0+15-8=7\). Each contains exactly three terms, matching the shared dimension.
Worked Example: A Product With Three Columns in the Answer
Let \(\mathbf{A}=\begin{bmatrix}1&-2\\0&3\\4&1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&1&0\\-1&3&5\end{bmatrix}\). The shared dimension is \(2\), so each entry uses two products. The result has three rows and three columns.
For row 1, the three entries are \(c_{11}=1(2)+(-2)(-1)=2+2=4\), \(c_{12}=1(1)+(-2)(3)=1-6=-5\), and \(c_{13}=1(0)+(-2)(5)=0-10=-10\).
For row 2, they are \(c_{21}=0(2)+3(-1)=0-3=-3\), \(c_{22}=0(1)+3(3)=0+9=9\), and \(c_{23}=0(0)+3(5)=0+15=15\).
For row 3, they are \(c_{31}=4(2)+1(-1)=8-1=7\), \(c_{32}=4(1)+1(3)=4+3=7\), and \(c_{33}=4(0)+1(5)=0+5=5\). Thus
Check: Substitution into the indexed formula reproduces every entry: row 1 gives \(4,-5,-10\); row 2 gives \(-3,9,15\); and row 3 gives \(7,7,5\). The displayed matrix has the required three rows and three columns.
The Special Case of One Row and One Column
A useful way to recognize the entry formula is to take a matrix with one row and a matrix with one column. If \(x_1,\ldots,x_n\) and \(y_1,\ldots,y_n\) are real numbers, then the product of the \(1\times n\) matrix \(\begin{bmatrix}x_1&\cdots&x_n\end{bmatrix}\) and the \(n\times1\) matrix \(\begin{bmatrix}y_1\\ \vdots\\y_n\end{bmatrix}\) is a \(1\times1\) matrix. Its only entry is \(\sum_{k=1}^{n}x_ky_k\), the sum of matching coordinate products.
Proof. The only entry has row index \(i=1\) and column index \(j=1\). Substituting these indices into the entry formula gives \(c_{11}=\sum_{k=1}^{n}a_{1k}b_{k1}\). Writing the entries of the first factor as \(x_k=a_{1k}\) and those of the second as \(y_k=b_{k1}\) yields \(c_{11}=\sum_{k=1}^{n}x_ky_k\). There are no other row or column positions in a \(1\times1\) matrix, so this is the entire product. \(\square\)
This special case helps explain why the indexed formula is often described using a row and a column. It does not change the rule: for every product entry, the chosen row and column contribute one paired product for each position in the shared dimension.
Common Indexing Pitfalls
Using the wrong column in the second factor. Consider \(\mathbf{A}=\begin{bmatrix}1&2\\3&4\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}5&6\\7&8\end{bmatrix}\). A wrong calculation for \(c_{12}\) is \(1(5)+2(7)=19\): it uses column 1 of \(\mathbf{B}\), rather than column 2. The indices in the formula expose the error: \(c_{12}=a_{11}b_{12}+a_{12}b_{22}\), so the correct calculation is \(1(6)+2(8)=6+16=22\). The first index of \(b_{kj}\) must be the shared index, and its second index must be the chosen output-column index \(j=2\).
Stopping the sum too soon or running it too far. The summation index \(k\) runs across the full shared dimension, not across the number of rows of the answer or columns of the answer. In the rectangular example above, the shared dimension is \(3\), so each entry has three terms even though the answer has only two rows and two columns. Leaving out the third term would calculate a different number; adding a fourth term would refer to an entry that does not exist in either factor.
Checking dimensions does not replace checking indices. A product can have valid dimensions and still be calculated incorrectly. A reliable entry check records \(i\) and \(j\), writes \(a_{ik}b_{kj}\), and lists all values of \(k\) before substituting numbers. This keeps the answer’s position and the paired entries separate.
Check Your Understanding
For each question, write the relevant indexed formula before substituting values.
- If \(\mathbf{A}\) is \(3\times4\) and \(\mathbf{B}\) is \(4\times2\), what are the dimensions of \(\mathbf{A}\mathbf{B}\), and how many terms occur in each entry sum?
- For \(\mathbf{A}=\begin{bmatrix}2&1\\-1&3\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}4&0\\5&-2\end{bmatrix}\), calculate \(c_{21}\) and \(c_{22}\).
- Write the full summation formula for \(c_{23}\) when \(\mathbf{A}\) has three columns and \(\mathbf{B}\) has three rows.
- In a \(1\times n\) times \(n\times1\) product, how many entries are in the answer, and what sum gives its only entry?
- Explain why using \(b_{jk}\) in place of \(b_{kj}\) can select the wrong entries for a product entry.