How to multiply matrices: dimensions and worked examples
To multiply two matrices, we combine a row from the first matrix with a column from the second. The dimensions tell us whether those pairs fit and how large the answer will be. Let’s check that setup, then calculate every entry of a product.
Check the matrix dimensions first
Matrix dimensions are written as rows × columns. If A is m × n and B is n × p, the product AB is defined and has dimensions m × p.
The number of columns in A must equal the number of rows in B. For example, a 2 × 3 matrix times a 3 × 4 matrix gives a 2 × 4 matrix. Reversing that order gives 3 × 4 times 2 × 3, whose inner dimensions do not match, so that reversed product is undefined.
Example: Multiply two 2 × 2 matrices
Both matrices are 2 × 2, so AB is defined and is also 2 × 2. Each entry comes from a row-by-column dot product: multiply the matching components, then add the products.
For row 1, column 1, use row (2, 6) from A and column (−4, 1) from B.
For row 1, column 2, keep the first row of A and use the second column of B.
Now use the second row of A for the two entries in the second row of AB.
Place each result in the row and column that produced it.
Why the order matters
Even when both AB and BA are defined, their entries can differ. For these same matrices, reversing the order gives
That is a different matrix, so this example shows why matrix multiplication is not commutative. Some matrix pairs do commute, but exchanging the order is not a general multiplication rule.
Multiplying a matrix by a scalar
A scalar is a single number. To multiply a matrix by a scalar, multiply every entry by that number. For example,
Associative and distributive properties
When the dimensions permit the operations, matrix multiplication is associative, so we can change the grouping while keeping the order:
It is also distributive:
Identity matrices, inverses, and zero matrices
An identity matrix has 1s on its main diagonal and 0s elsewhere. Multiplying by the identity of the appropriate size leaves a matrix unchanged. The 2 × 2 identity is
For an m × n matrix A, we have IₘA = A and AIₙ = A. If a square matrix has an inverse A⁻¹, multiplying A and its inverse in either order gives the identity. A square matrix need not have an inverse.
A zero matrix contains only zeros. Multiplying by a zero matrix gives a zero matrix whenever the dimensions make the product defined, with the resulting dimensions determined by the outer sizes as before.