Worked examples — Matrix multiplication — conditions, process, non-commutativity
This page is a drill through every kind of matrix-multiplication situation you can meet. We start by mapping out all the case classes on one table, then work an example for each cell so you never hit a scenario you haven't already seen. Most examples carry a figure — the picture usually explains the "why" faster than the arithmetic does.
Before we start, one reminder from the parent note — every entry of a product is built the same way:
Throughout this page the zero matrix is written (boldface), so it is never mistaken for a variable named .
The scenario matrix
Every problem below falls into exactly one of these cells. Each "Example" cell names the section you can jump to.
| # | Case class | What makes it tricky | Worked in |
|---|---|---|---|
| A | Rectangular × rectangular (valid) | shapes differ, must track dimensions | Example 1 |
| B | Matrix × column vector | this is what "apply a transformation" means | Example 2 |
| C | Non-commutativity () | order changes the answer | Example 3 |
| D | Zero / degenerate inputs | multiplying by ; with | Example 4 |
| E | Identity & sign patterns | negatives, all four sign combinations | Example 5 |
| F | Undefined product | inner dimensions clash → STOP | Example 6 |
| G | Word problem (real units) | reading meaning off the numbers | Example 7 |
| H | Exam twist ( does hold) | when commuting is actually true, and why | Example 8 |
[!example] Example 1 — Case A: rectangular × rectangular
Compute . The figure below shows the shapes locking together — the two red inner numbers touch, and the green outer numbers become the answer's size.

Forecast: Before reading on — what shape is the answer, and is it even allowed? (Cover the next line.)
Steps:
-
Shape check. is , is . Inner numbers match () ✓. Answer is . Why this step? If the reds clashed we would stop; there is no product to compute — exactly the dominoes-don't-meet situation drawn in the figure.
-
= row 1 of · column 1 of : Why this step? We slide row against column , multiply matched slots, add. That single number lives in position (1,1).
-
= row 1 · column 2: Why this step? Same row of , but now the second column of — that is what makes it column 2 of the answer.
-
= row 2 · column 1: Why this step? We switch to the second row of to fill the second row of the answer; the column of is unchanged, so we stay in column 1.
-
= row 2 · column 2: Why this step? Last empty slot: row 2 of with column 2 of completes the grid.
Verify: Shape is as predicted ✓. Quick sanity check on : the biggest positive terms () plus give — no negatives in that row/column, so a large positive is expected ✓.
[!example] Example 2 — Case B: matrix times a column vector
A matrix acting on a vector is the whole reason multiplication is defined the way it is: it applies a transformation.
Compute and describe what it did geometrically.
What to look for in the figure: the lavender arrow is the input ; the coral arrow is the output ; the mint arc marks the counter-clockwise turn between them. Notice both arrows have the same length — the transformation only spins, it does not stretch.

Forecast: This particular is a famous transformation. Guess what it does to the arrow before computing.
Steps:
-
Shape check. is , is . Match ✓. Result is (a column vector again). Why this step? A transformation should return a vector, and confirms that.
-
First entry = row 1 · the column: Why this step? Row 1 of decides the new -component of the arrow.
-
Second entry = row 2 · the column: Why this step? Row 2 of decides the new -component; each output slot is one row of dotted with — the row tells you how to mix the input's components.
-
Interpret. The arrow became — look at the mint arc in the figure: it swung a quarter turn counter-clockwise (90°). This is the rotation-by-90° matrix.
Verify: A 90° rotation must preserve length. and ✓. It must also keep the two arrows perpendicular: ✓ (dot product zero = right angle). This ties to Linear transformations.
[!example] Example 3 — Case C: order matters ()
Compute both and .
What to look for in the figure: we track the corner point (top of the unit square). The left panel does stretch then shear () and the point lands at ; the right panel does shear then stretch () and the same start lands at . Two different final places = order matters.

Forecast: Do you expect them to be equal? (Almost never — guess which entry disagrees.)
Steps:
-
(shear-of-a-stretch): Why this step? Reading right-to-left, means "do (stretch) first, then (shear)" — the left panel of the figure.
-
(stretch-of-a-shear): Why compute both? Because "matrices are numbers, numbers commute" is a trap. The top-right entry differs ( vs ) — the right panel lands the corner further along.
-
Conclusion: . The entry is one way and the other.
Verify: They agree in three entries and differ in one, so ✓. This is exactly the non-commutativity the parent warns about: doing things in a different order gives a different result.
[!example] Example 4 — Case D: zero & degenerate inputs
Two sub-cases that surprise people.
(4a) Multiply by the zero matrix :
(4b) Two non-zero matrices whose product is zero:
What to look for in the figure: the panel shows why geometrically — squashes the whole plane onto a single line (mint), and 's output arrows (coral) land exactly along the direction kills, so then flattens them to the origin.

Forecast: For (4b), can two matrices that are clearly not zero multiply to give the zero matrix? (With ordinary numbers this is impossible.)
Steps:
-
(4a) Every entry of is a row of dotted with a column of zeros, so every term is : Why this step? Confirms the "zero property" from the parent — a dot product with an all-zero list is always .
-
(4b) Compute entry by entry: Why this matters: Yes! even though and . So you cannot cancel matrices like numbers.
Verify: For (4b) each entry is ✓. Note and : both are degenerate (zero determinant). Only such "flattening" matrices can multiply to zero without being zero — a hint that neither has an inverse.
[!example] Example 5 — Case E: identity and all sign combinations
Compute and . (This forces us through all four sign patterns: .)
What to look for in the figure: a test arrow (lavender) is left unmoved by , and sent to its exact opposite (coral, pointing through the origin) by — a flip.

Forecast: What does multiplying by do? What about ?
Steps:
-
: Why this step? The Identity matrix is the "multiply-by-1" of matrices; each row of picks out itself. Nothing changes.
-
(here ): Why this step? Multiplying by flips every sign — watch how each of the four entries reverses, covering and .
Verify: exactly ✓. And since : adding gives all zeros ✓ (uses Matrix addition and scalar multiplication).
[!example] Example 6 — Case F: undefined product (STOP)
Compute .
What to look for in the figure: the shapes are laid side by side. For the two inner numbers ( and ) are drawn with a red gap — they don't meet, so the product cannot form. Flip to and the inner numbers ( and ) touch (green), so that order is legal.

Forecast: Look at the shapes only — is this legal?
Steps:
-
Shape check. is , is . Inner numbers are and — they clash () ✗. Why this step? Row of has entries, but each column of has only entries. You cannot form a dot product between lists of different length.
-
Conclusion: is undefined. Do not compute anything.
-
Flip it: is legal? is , is : inner ✓, so is defined and is . One order works, the other doesn't. Why show the flip? To hammer home that "undefined" is about order and shape, not about the matrices being "bad." The very same two matrices multiply fine the other way round — so you must always check shapes for the specific order you were asked about.
Verify: No number to check — the check is structural: so "undefined" is the correct and complete answer. This is why the parent insists on writing dimensions first.
[!example] Example 7 — Case G: word problem with real units
A shop makes two smoothies. The recipe matrix (rows = smoothie, columns = fruit: banana, apple) and the price matrix (rows = fruit, columns = store 1, store 2):
Find the cost of each smoothie in each store.
What to look for in the figure: the four resulting costs shown as a labelled grid (smoothie × store), so you can see the meaning of each entry rather than just a number.

Forecast: Which product — or — has meaning here? Match the units first.
Steps:
-
Match units. Columns of = fruits; rows of = fruits. They line up, so is the meaningful product ( times : smoothie × store). Why this step? The inner index must be "the same thing" (fruit) or the sum is nonsense — you can't add "bananas × ₹/apple."
-
Cost of smoothie A (row 1 of ):
- Store 1:
- Store 2: Why this step? Row 1 of is smoothie A's fruit counts; dotting with a store's price column gives that smoothie's bill in that store.
-
Cost of smoothie B (row 2 of ):
- Store 1:
- Store 2: Why this step? We switch to row 2 of (smoothie B's recipe); each store's price column again gives one total, filling the second row of the answer.
Verify: Units: (fruit count)×(₹ per fruit) = ₹ ✓. Smoothie B uses more apples (the pricier fruit at store 1), so its store-1 cost () should top smoothie A's () — it does ✓.
[!example] Example 8 — Case H: exam twist, when does hold
Show , and explain why order stops mattering here.
What to look for in the figure: both matrices only stretch along the - and -axes (no tilting). Because each acts on its own axis independently, doing them in either order scales each axis by the product of the two factors — the same both ways.

Forecast: We said matrices usually don't commute. Why might these two be an exception?
Steps:
-
: Why this step? For diagonal matrices only the matching diagonal slots interact, so the product's diagonal is just and .
-
: Why they match: the same diagonal numbers multiply, and ordinary number multiplication is commutative (). No off-diagonal mixing happens.
-
Conclusion: . Commuting is a special case, not the rule — here it works because each matrix only stretches along the axes, and stretch-then-stretch has no order dependence.
Verify: Both products equal so ✓. Contrast Example 3, where a shear mixed the axes and commutativity failed.
[!recall]- Scenario check — cover the answers
Which product is legal: or ?
Can with ?
What does multiplying by do to a matrix?
When is guaranteed for diagonal matrices?
In the smoothie problem, why and not ?
Connections
- Linear transformations — Example 2's rotation is the geometric meaning of .
- Identity matrix — Example 5 shows .
- Determinants — Example 4b's zero products both have zero determinant.
- Inverse of a matrix — the degenerate matrices in Example 4 have no inverse.
- Matrix addition and scalar multiplication — used in the Example 5 sign check.
- System of linear equations — matrix-vector products (Example 2) power .