Matrix multiplication records the combined effect of two successive linear calculations. Its row-by-column rule comes from substituting the output of the first calculation into the second.
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.
For a concrete example, first form and , then form and . Substitution gives
Each coefficient combines a row of the second calculation with a column of the first. Writing those coefficient arrays as and , respectively, the array for the combined calculation is : the rightmost factor acts first.
Open the guided matrix walkthrough in MATH1030
Definition 2.1.1
(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 2.1.2
(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.
Open the guided matrix walkthrough in MATH1030
Worked example 2.1.3
(Compute a product carefully)
Let
Then is defined because both matrices are . Its entries are:
So
Open the guided matrix walkthrough in MATH1030
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
Each row of supplies the coefficients of one equation in .
Identity matrices do nothing, on purpose
Definition 2.1.4
(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 2.1.5
(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
An entry of combines one row and one column. Identity multiplication preserves each compatible row or column.
Multiplication is usually not commutative
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.
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 2.1.6
(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 2.1.7
(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 2.1.8
(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 2.1.9
(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.
Proof of the finite real matrix product laws
Let be positive integers, let , , and . All the following arguments use the row-by-column definition and finite real sums. For any output position ,
The middle equality only reorders two finite sums and uses real distributivity. Both products are , so equality at every position proves associativity. No factor has changed its order.
For , the same definition gives
For , it gives
Thus both distributive laws hold with the displayed matching sizes. For every real scalar ,
proving by entrywise equality. In particular, for and real ,
This proves the matrix-vector linearity used when comparing solutions of the same linear system. All identities concern compatible finite real matrices; they do not assert commutativity or cancellation of arbitrary matrix factors.
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 2.1.10
(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 2.1.11
(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 2.1.12
(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 2.1.13
(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
Quick check
(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 .
Quick check
(What does multiplying by do to a compatible matrix?)
Answer in one sentence.
Solution · Answer
It leaves the matrix unchanged.
Quick check
(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 .
Quick check
(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
Quick check
(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.
Quick check
(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.
Quick check
(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.
Quick check
(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 .
Quick check
(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 1.2 Matrix basics. Continue to 2.2 Transpose, symmetric, and skew-symmetric matrices or jump ahead to 2.3 Invertible matrices.