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.
Motivation
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.
There is also a structural reason for this dimension rule. An matrix sends a vector with entries to one with entries, and an matrix can then accept that output and send it to a vector with entries. Thus followed by has the size , exactly the size of . The matching inner dimension is the space through which the two actions connect; the outer dimensions record the input and output of the combined action.
Definition
When a matrix product is defined
If is an matrix and is an matrix, then the product is defined and is an matrix.
If the number of columns of does not equal the number of rows of , then the product 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 entry of is
So each output entry is the dot-product-style combination of row of with column 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 is defined because both matrices are . Its entries are:
So
Matrix-vector multiplication is a system statement
If is a column vector, then 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.
Read Ax one equation at a time
The sequence below keeps the same symbolic by product visible as the rows of become the equations inside . Use it as a bridge between the formula above and the editable multiplication visualizer later in the note.
Follow how row-by-column multiplication turns Ax = b into a complete system, one row equation at a time.
Match the sizes
A 2 x 3 matrix can multiply a 3 x 1 vector because each row of A has exactly three entries to pair with x.
Read row 1
The first output entry is the first row of A paired with x: a11*x1 + a12*x2 + a13*x3.
Set it equal to b1
When Ax = b, that first output entry becomes the first equation of the system.
Read row 2
The second row gives the second equation: a21*x1 + a22*x2 + a23*x3 = b2.
Stack the equations
Ax = bis the vertical stack of all row equations, written as one matrix equation.Extend to AB
If B = [u v], then AB = [Au Av]. A general product is several Ax-style products side by side.
The row-by-column rule is why one compact equation, Ax = b, can store an entire linear system. Each row of A supplies one equation; a full product AB repeats the same idea once for every column of B.
Identity matrices do nothing, on purpose
Definition
Identity matrix
For each positive integer , the identity matrix is the square matrix with on the main diagonal and 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 .
Compare a general product with identity multiplication
The next sequence separates the two mechanics that matter most here: a single entry of is built from one row and one column, while multiplying by an identity matrix preserves the compatible rows or columns. After comparing the cases, use the interactive visualizer below to choose individual output entries yourself.
Follow one matrix product entry form from a row-column sum, then see why multiplying by an identity matrix preserves rows and columns.
Size gate
A 2 x 3 matrix can multiply a 3 x 2 matrix because the inner sizes match. The outer sizes make AB a 2 x 2 matrix.
One entry
The top-left output entry uses row 1 of A and column 1 of B: c11 = 1*4 + 2*5 + (-1)*6 = 8.
Whole product
Repeat the row-column rule for every output cell. The product is not built by multiplying corresponding positions.
Right identity
In A I_n = A, the columns of I_n select the columns of A, so right multiplication by the identity preserves A.
Left identity
In I_m A = A, the rows of I_m select the rows of A, so left multiplication by the identity also preserves A.
Order warning
Identity matrices are special. In general AB and BA ask different row-column questions and need not be equal.
A matrix product is defined by compatible inner sizes. Each output entry is a row-column sum, and identity matrices preserve compatible matrices because their rows and columns select the original rows and columns.
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.
Counterexample mode
Matching dimensions do not guarantee commutativity
The claim “two square matrices of the same size always satisfy ” is false even though both products exist and have the same size. Take
Both are real matrices, so the hypothesis is satisfied. Direct row-by-column multiplication gives
For example, , whereas . One unequal corresponding entry is enough to prove . The failure has a structural explanation: multiplying this on the right keeps the second column and zeros the first, while multiplying it on the left keeps the second row and zeros the first.
A valid replacement is: a square matrix commutes with every scalar multiple of the identity of the same size. Indeed, if , then . For arbitrary square matrices, commutativity needs its own justification; matching dimensions guarantees that multiplication is defined, not that factors can be interchanged.
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 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 is first sent to , and then that result is sent to , 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 and are defined, so both and make sense, and associativity says they are equal. More explicitly, is , so is ; meanwhile, is , so is also .
But is not defined at all, because the inner dimensions and 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 in position and everywhere else. If is an matrix, then is exactly the th 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 .
Theorem
A matrix is determined by its action on vectors
Let and be matrices. If
then .
Proof
Proof using the standard basis
For each , substitute the standard basis vector into the hypothesis. This gives . But is the th column of , and is the th column of . Hence the two matrices have the same th column for every . All their columns, and therefore all their entries, are equal, so .
The words "for every " are essential. Two different matrices can agree on one particular vector—for example, both send the zero vector to zero. The proof also shows something sharper: it is enough to check the standard basis vectors, because their images reveal the columns one at a time.
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 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.
Unknown entries and the order of factors
A product with unknown entries brings three ideas together: compatible dimensions, the row and column that determine each output entry, and the order of the factors. Use those structural facts before solving the resulting scalar equations.
Worked example
Recover unknowns from a partially known product
Let
Suppose
The product is defined because is and is , so must be . Computing only the entries we need gives
Comparing the first column with the given matrix gives
Thus
Subtracting the first equation from the second gives , and then . The remaining entries are
This kind of problem is not really about multiplying every entry in sight. It is about extracting the few equations that the known product entries force.
Worked example
Expand products without pretending matrices commute
Let and be square matrices of the same size. Then
Now distribute on the right:
The middle terms are and . They cannot be combined into unless you already know that .
The same warning explains a common false shortcut:
This equals only under the extra condition . Real-number algebra hides this issue because real-number multiplication is commutative. Matrix algebra does not.
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
Take . Then the defining property of gives . But right-multiplying any matrix by leaves it unchanged, so . Therefore .
Common mistakes
Common mistake
Matrix multiplication is not entrywise multiplication
The entry is not . It is built from the whole th row of and the whole th column of .
Common mistake
Defined products can still appear in only one order
If is and is , then is defined but is not. Never assume the reverse order makes sense automatically.
Common mistake
Column language belongs to the right-hand factor
If , then . The columns of the product are linear combinations of the columns of , using weights from the corresponding columns of . Do not write ; that expression does not match the definition of matrix multiplication.
Common mistake
Binomial formulas need commutation hypotheses
The formula is not automatic for matrices. The actual expansion is
You may combine the middle terms only when .
Summary
For of size and of size , the product has size ; incompatible inner dimensions make the product undefined. Each entry comes from one row of and one column of , while the column formula reads the same operation as several matrix-vector products. In particular, packages a linear system.
Identity matrices preserve compatible matrices. Matrix multiplication is associative and distributive, but associativity only changes parentheses: it does not justify changing the order of factors, and in general . Finally, the identities show that the action of a matrix on the standard basis determines every column. Consequently, if for every vector in , then .
Quick checks
Checkpoint
If is and is , what is the size of ?
Use the inner dimensions to test whether the product is defined, then read the outer dimensions.
Solution · Answer
is defined and has size .
Checkpoint
What does multiplying by do to a compatible matrix?
Answer in one sentence.
Solution · Answer
It leaves the matrix unchanged.
Checkpoint
If the columns of are and , how should you read the columns of ?
Use the column interpretation of matrix multiplication.
Solution · Answer
The columns of are and .
Checkpoint
In , what is the coefficient of after expansion?
Keep and as different terms.
Solution · Answer
The coefficient of is , because the term comes from .
Exercises
Checkpoint
Why does represent several equations at once?
Use the word "rows" in your answer.
Solution · Answer
Each row of produces one equation when it is paired with the column vector , so the product packages all those row equations together.
Checkpoint
Why does always have at least one solution, no matter what is?
Think of as a column vector.
Solution · Guided solution
Take the zero vector . Every entry of is a linear combination of the entries of , so every entry is . Hence , and the homogeneous system always has the trivial solution.
Checkpoint
Explain why may be undefined even when is defined.
Answer in terms of the inner dimensions, not just by giving one example.
Solution · Guided solution
For to be defined, the number of columns of must equal the number of rows of . For to be defined, the number of columns of must equal the number of rows of . These are different conditions, so one order may be legal while the reverse order is not.
Checkpoint
Let and be the matrices from the worked example with unknowns. If the first column of is , find and .
Use only the equations coming from the first column.
Solution · Guided solution
The first column of gives
So
Subtracting gives , and substituting into gives .
Checkpoint
Write the first entry of when the first row of is and .
Use the row-by-column rule.
Solution · Guided solution
The first entry is .
Related notes
This note depends on 2.1 Matrix basics. Continue to 3.3 Transpose, symmetric, and skew-symmetric matrices or jump ahead to 5.1 Invertible matrices.