Britannica Sources used in this answer

How is each entry in a matrix product calculated?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

To calculate the product of two matrices, A and B, the number of columns in A must equal the number of rows in B. The resulting matrix C is formed by calculating each entry cij, which represents the element in the ith row and jth column of the product.

To find cij, you perform a dot product operation: multiply the first element of the ith row of A by the first element of the jth column of B, then multiply the second element of the row by the second element of the column, and continue this process for all corresponding elements. The sum of all these individual products equals the value of cij.1

In mathematical notation, if A has m columns and B has m rows, the entry is calculated as:
cij=∑k=1maikbkj

The resulting matrix C will have the same number of rows as A and the same number of columns as B.1