Matrix multiplication is the first matrix operation that genuinely mixes rows with columns. It is also the operation that lets matrices encode composition, systems of equations, and later inverse matrices. Because of that, you should not memorize the rule as a pattern of symbols only. You should know what the dimensions are doing at each step.
Why multiplication is more subtle than addition
Addition and scalar multiplication act entry by entry. Matrix multiplication is different. To compute one output entry, you compare one row of the left matrix with one column of the right matrix.
That is why dimensions matter so strictly.
Definition
When a matrix product is defined
If is an matrix and is an matrix, then the
product AB is defined and is an matrix.
If the number of columns of does not equal the number of rows of , then
the product AB is undefined.
The inner dimensions must match. The outer dimensions tell you the size of the result.
The row-by-column rule
Definition
Matrix multiplication
Suppose is an matrix and is an matrix.
Then the (i,k) entry of AB is
So each output entry is the dot-product-style combination of row i of
with column k of .
This rule explains three important facts at once:
- multiplication is not entrywise;
- the inner dimensions must match;
- the output entry uses every matched position in the row and column.
Worked example
Compute a product carefully
Let
Then AB is defined because both matrices are . Its entries are:
So
Matrix-vector multiplication is a system statement
If x is a column vector, then Ax is a special case of matrix multiplication.
It packages the left-hand sides of a linear system into one object.
For
we have
So the system is not merely shorthand. It is a matrix product whose entries reproduce the equations of the system.
Identity matrices do nothing, on purpose
Definition
Identity matrix
For each positive integer n, the identity matrix is the
square matrix with 1 on the main diagonal and 0 everywhere else.
For example,
The identity matrix matters because it preserves any compatible matrix:
whenever the sizes match.
Worked example
Why multiplying by the identity changes nothing
Let
Then
The first column of reproduces the first column of , and the second column reproduces the second column of .
That is exactly why inverse matrices are defined through the identity later: if exists, then .
Multiplication is usually not commutative
One of the first conceptual shocks in linear algebra is that
in general.
Sometimes both products are defined and differ. Sometimes one product is defined and the other is not. So order matters twice: it matters for meaning, and it matters for the final answer.
Use the figure below to watch one output entry being built from a selected row and a selected column.
Read and try
Follow one matrix product entry
The live widget updates each entry of AB as you change the entries of A and B.
Result
| 8 | 9 |
| 3 | 4 |
8 = 1×2 + 2×3
Common mistakes
Common mistake
Matrix multiplication is not entrywise multiplication
The entry is not . It is built from the whole ith
row of and the whole kth column of .
Common mistake
Defined products can still appear in only one order
If is and is , then AB is defined but BA
is not. Never assume the reverse order makes sense automatically.
Quick checks
Quick check
If is and is , what is the size of AB?
Use the inner dimensions to test whether the product is defined, then read the outer dimensions.
Solution
Answer
Quick check
What does multiplying by do to a compatible matrix?
Answer in one sentence.
Solution
Answer
Exercise
Quick check
Why does always have at least one solution, no matter what is?
Think of x as a column vector.
Solution
Guided solution
Related notes
This note depends on 2.1 Matrix basics. Continue to 3.2 Transpose and special matrices or jump ahead to 5.1 Invertible matrices.