The product of matrices is not done element by element: it follows the row-by-column rule, and for this reason it requires the dimensions to be compatible.

Property — Row-by-column product

If AA is m×pm\times p and BB is p×np\times n, the product C=ABC=AB is m×nm\times n with cij=k=1paikbkj.c_{ij} = \sum_{k=1}^{p} a_{ik}\,b_{kj}. Mnemonic: “row ii of AA against column jj of BB”. The dimensions must “glue together”: (m×p)(p×n)=m×n(m\times p)(p\times n) = m\times n. It is not commutative: in general ABBAAB\ne BA even when both products are defined.

Connections

Topics: Linear systems
Concepts: Matrix · Product of matrices
Skills: Using formulae