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
Read the product by columns as well as by entries
The row-by-column rule is the standard local computation rule, but it is not the only useful interpretation.
Write the columns of as
Then the product can be read as
So each column of AB is obtained by applying to the corresponding column
of .
Worked example
One product read column by column
Let
If
then
Therefore
This is the same answer as the entrywise row-by-column computation. The point is that matrix multiplication packages several matrix-vector products together.
Matrix multiplication represents composition
The multiplication rule is not arbitrary. It is the rule that makes matrices encode linear transformations in sequence.
If a vector x is first sent to Bx, and then that result is sent to
A(Bx), the combined effect is
That is why the inner dimensions must match. The output of the first map must be a valid input for the second one.
Theorem
Associativity matches repeated composition
Whenever the products are defined,
So we may regroup a chain of matrix products without changing the final linear transformation.
This does not mean that order may be changed. Associativity lets us change parentheses, not the order of the factors themselves.
Worked example
Grouping may change, but order may not
Suppose is , is , and is .
Then both AB and BC are defined, so both (AB)C and A(BC) make sense,
and associativity says they are equal.
But BA is not defined at all, because the inner dimensions 4 and 2 do not
match. So matrix multiplication is associative, but not commutative.
Standard basis vectors explain why columns behave so cleanly
The standard basis vectors make the column interpretation precise. In ,
the vector has a 1 in position k and 0 everywhere else. If is
an matrix, then is exactly the kth column of .
This is why the identity matrix behaves so naturally. The columns of are , so right-multiplying by simply reproduces the columns of one by one.
This also explains why a compatible zero matrix on the right forces the product to be zero: every column of the zero matrix is the zero vector, so every column of the product is .
The first algebra laws worth remembering
Once multiplication is defined, the next issue is how it interacts with the other matrix operations you already know.
Whenever the sizes are compatible, matrix multiplication satisfies:
and scalar multiplication may be moved in or out:
The zero matrix is the simplest sanity check for these rules. If 0 is a
compatible zero matrix, then
The reason is that every row-by-column product uses only zero entries from the zero matrix, so every output entry is zero as well.
These identities are basic, but they matter because later arguments about inverse matrices, row operations, and block-matrix computation assume them silently. If you do not know them explicitly, longer calculations become much harder to audit.
Worked example
A zero product does not force a zero factor
Let
Neither factor is the zero matrix, yet
So matrix multiplication behaves differently from real-number multiplication: does not imply or .
Theorem
The identity matrix is unique
If is an matrix such that
for every compatible matrix , then .
Proof
Why no second identity matrix can exist
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
Quick check
If the columns of are and , how should you read the columns of AB?
Use the column interpretation of matrix multiplication.
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
Quick check
Explain why BA may be undefined even when AB is defined.
Answer in terms of the inner dimensions, not just by giving one example.
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.