Britannica Sources used in this answer

When can two matrices be multiplied?

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

In linear algebra, the multiplication of two matrices, A and B, is defined only when the number of columns in the first matrix (A) is equal to the number of rows in the second matrix (B).1

If matrix A is an m×n matrix and matrix B is an n×p matrix, the resulting product matrix will have dimensions m×p. The element in the ith row and jth column of the product is calculated by taking the sum of the products of corresponding elements from the ith row of A and the jth column of B.1

It is important to note that matrix multiplication is not commutative; in general, AB≠BA. However, it remains associative and distributive over addition when the operations are possible.1