To solve matrix multiplication problems, multiply each row of the left matrix by each column of the right matrix: pair element i of the row with element i of the column, sum the products, and place the result in that row-and-column position. The inner dimensions must match (an m×n times an n×p), and the output is m×p. Order matters: AB usually differs from BA.
This guide goes past the rule. You will see why the row-column rule is forced by linear combinations, how to catch dimension errors before doing arithmetic, where hand methods and machine methods diverge, and which shortcuts actually save time on exams and in code.
What the row-column rule is actually computing
Start with the shape contract. A matrix is a grid with rows and columns, written rows×columns. If A is 2×3 and B is 3×4, the shared inner number 3 is the contract: A supplies 3 entries per row, B consumes 3 entries per column. The result C is 2×4.
Now the deeper reason. Each column of B is a recipe for mixing the columns of A. Entry C[i][j] asks: how much of row i of A overlaps column j of B? The operation is a dot product. For C with A row (2, 1, 4) and B column (3, 0, 5), you compute 2·3 + 1·0 + 4·5 = 26. Every one of the m·p entries is one dot product of length n.
Two views explain why the rule exists. In the row view, row i of C is a weighted blend of the rows of B, with weights from row i of A. In the column view, column j of C is a blend of the columns of A, with weights from column j of B. Both views are consequences of linearity: matrix multiplication is defined so that C times a vector equals A times (B times that vector). Try the numbers and the definition stops looking arbitrary.
A small full example makes it concrete. Let A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]. Then AB = [[1·5+2·7, 1·6+2·8], [3·5+4·7, 3·6+4·8]] = [[19, 22], [43, 50]]. Compute BA and you get [[23, 34], [31, 46]]. Different matrix, same inputs.
Plain language: each output entry is one row-meets-column sum of products, and nothing else.
Quantified context: cost, size, and speed
The arithmetic cost of multiplying an m×n by an n×p matrix is m·n·p multiplications and about the same number of additions, a figure computer scientists call the operation count. For two 100×100 matrices, that is 1,000,000 multiplications. Double each side to 200×200 and the count jumps to 8,000,000, an eightfold rise for a twofold size increase.
This cubic scaling explains real behavior. A 1000×1000 product is 1 billion multiply-adds by the schoolbook method. Modern processors handle that in well under a second with optimized libraries, but naive triple-loop code can be 10 to 100 times slower because it ignores memory access patterns.
Machine learning depends on these numbers. Training and inference for neural networks are dominated by matrix multiplication, and hardware vendors build dedicated units for it. The practical lesson: hand computation is fine for small textbook matrices, but anything above roughly 5×5 by hand invites errors, and production code should call a library such as BLAS rather than write loops.
Dimension counts are your cheapest check. Before any arithmetic, write the shapes side by side. If a problem says A is 3×4 and B is 4×2, the product exists and is 3×2, and you expect 6 dot products of length 4 each.
Timeline: working through a multiplication
| Step | Action | Typical time (hand, 3×3 × 3×3) |
|---|---|---|
| 1 | Write both shapes and confirm inner match | 10–20 seconds |
| 2 | Write the output shape and a blank grid | 20–30 seconds |
| 3 | Compute the first row of the product | 1–2 minutes |
| 4 | Compute remaining rows, checking symmetry of effort | 3–6 minutes |
| 5 | Verify with a row-sum or column-sum test | 1–2 minutes |
| 6 | Reread the question and units or labels | Under 1 minute |
Total: roughly 6–12 minutes for a 3×3 by 3×3 product done carefully. Most errors appear in step 4, where attention drifts and row or column indices slip.
Edge cases and the traps they set
Non-square shapes are the normal case, not the exception. A 1×4 row times a 4×1 column yields a 1×1 result, a scalar-like quantity. A 4×1 column times a 1×4 row yields a full 4×4 matrix. These two products use identical entries and give wildly different answers, which is why writing shapes first matters.
Order sensitivity is the big trap. AB = BA holds only for special pairs, such as a matrix with the identity or scalar multiples of it. In general commutativity fails, and a problem that asks for BA when you computed AB is wrong even if every digit is right.
Another edge case: the identity matrix I acts like 1, leaving any conformable matrix unchanged. The zero matrix acts like 0, and products involving it collapse to zero. Watch for these in proofs and in exam shortcuts.
What if dimensions do not match? The product is simply undefined. No rearrangement fixes it. That is a legitimate answer to many problems, and stating it cleanly beats forcing arithmetic.
Red flags that predict a wrong answer:
You wrote the result shape before checking the inner dimensions. You multiplied corresponding entries instead of row by column. You assumed AB equals BA without checking. You lost track of a row after a line break or page turn.
Misconceptions worth unlearning
The most common misconception is that matrix multiplication works like scalar multiplication entry by entry. It does not. The Hadamard product, which does multiply matching entries, exists but is a separate operation with its own uses in statistics and image processing.
A second misconception treats order as irrelevant. Swap the operands and the answer usually changes, and sometimes the product stops existing at all, since a 2×3 times a 3×4 works while the reverse does not.
A third misconception conflates multiplication with row reduction. Gaussian elimination transforms one matrix; multiplication combines two. They share arithmetic skills but answer different questions.
The counterintuitive professional caveat: the answer "undefined" is correct more often than students expect. In linear algebra coursework, a meaningful share of multiplication problems test shape recognition rather than arithmetic. Professionals spot an impossible product instantly and move on.
A fourth misconception: the determinant of AB equals det(A) times det(B) only for square matrices of the same size. True, but it does not mean the products AB and BA differ in determinant, because det(AB) and det(BA) are equal even when the matrices differ. Details like this are why checking against known identities pays off.
Applying it: a practical method
The method below works for hand work, code review, and exam settings.
Write shapes. Put m×n beside n×p and confirm the inner values match. Write the output shape m×p immediately. If they do not match, stop and state that the product is undefined. Draw a blank grid. Sketch an m×p grid of empty cells. This prevents row and column mix-ups later. Work row by row, then entry by entry. For each cell, say the row aloud or point to it, then slide across the matching column. Compute the full dot product before moving on. Use a verification test. The sum of the entries in each row of C should equal the corresponding row of A times the column of ones in B, which is a fast consistency check. Recheck with a second view. Recompute one entry using the column view (blend the columns of A). If the numbers disagree, you found a slip. In code, call the library. Use an optimized routine for anything larger than a toy matrix, and verify shapes in a test before multiplying.
Comparison of hand methods:
| Method | Best for | Strength | Weakness |
|---|---|---|---|
| Direct row-column | Any conformable pair | Transparent, no setup | Slow for large matrices |
| Row combination | Interpreting results | Shows meaning fast | Easy to mis-blend |
| Column combination | Interpreting results | Matches linear systems | Easy to mis-blend |
| Block multiplication | Large structured matrices | Divides the work | Requires careful shape bookkeeping |
| Transpose trick | Explaining AB as BᵀAᵀ | Good for proofs | Not faster to compute |
Plain language: pick the view that matches the question, but use the direct method to get digits.
Limitations and what hand methods miss
Schoolbook multiplication is exact and fine for small problems, but it is not what production systems use. Libraries partition work into blocks, reorder loops for memory locality, and exploit parallel hardware; the arithmetic is equivalent, yet the speed differs by orders of magnitude. Comparing a hand result to library output should therefore check values, not timing.
Floating-point arithmetic introduces rounding. Two mathematically equal computations can differ in the last digits depending on order, which matters when comparing results across systems. Costs and hardware prices change over time and are deliberately omitted here, since they would go stale and are not needed to understand the method.
Hand methods also fail to scale philosophically: they build intuition for two or three matrices but say nothing about stability or conditioning of products. Those topics belong to numerical linear algebra and deserve separate study. Finally, this article teaches the mechanism, not exam-specific conventions, which vary by instructor and course.