Matrix Multiplication- Understanding the Process
What Matrix Multiplication Actually Is
Matrix multiplication is a way to combine two grids of numbers into a single grid. It's not the same as multiplying every element by the same number. That's called scalar multiplication. This is different.
You take rows from the first matrix and columns from the second matrix. Pair them up, multiply, add the results. That's the dot product method. Sounds simple. It is simple. The catch is the dimensions have to line up correctly.
The Dimension Rule You Can't Ignore
Before you touch a single number, check your dimensions. This trips up almost everyone at first.
If matrix A has dimensions m ร n (m rows, n columns) and matrix B has dimensions n ร p (n rows, p columns), then you can multiply them. The result will be an m ร p matrix.
The inner dimensions must match. That's the only requirement. The outer dimensions tell you the size of your answer.
- (3 ร 2) ร (2 ร 4) = (3 ร 4)
- (4 ร 3) ร (3 ร 5) = (4 ร 5)
- (2 ร 5) ร (3 ร 2) = Can't multiply โ 5 โ 3
How to Actually Do the Multiplication
Here's the step-by-step process. No shortcuts, just the method that works every time.
Step 1: Find the Dot Product
For each element in the result matrix, you compute a dot product. Take one row from the left matrix and one column from the right matrix. Multiply corresponding elements, then add everything up.
Row [a, b] ร Column [c, d] = (a ร c) + (b ร d)
Step 2: Work Through the Grid
Element (i, j) in the result comes from row i of the left matrix and column j of the right matrix. Fill in the grid systematically. Row 1, Column 1. Row 1, Column 2. Keep going until the grid is full.
Step 3: Don't Rearrange the Order
Matrix multiplication is not commutative. A ร B does not equal B ร A in most cases. Sometimes B ร A doesn't even work when A ร B does, because of the dimension rule.
A Worked Example
Let's multiply:
Matrix A (2 ร 3):
[1, 2, 3]
[4, 5, 6]
Matrix B (3 ร 2):
[7, 8]
[9, 10]
[11, 12]
Result will be (2 ร 2). Let's find the four elements.
Element (1,1): Row [1,2,3] ยท Column [7,9,11]
= (1ร7) + (2ร9) + (3ร11) = 7 + 18 + 33 = 58
Element (1,2): Row [1,2,3] ยท Column [8,10,12]
= (1ร8) + (2ร10) + (3ร12) = 8 + 20 + 36 = 64
Element (2,1): Row [4,5,6] ยท Column [7,9,11]
= (4ร7) + (5ร9) + (6ร11) = 28 + 45 + 66 = 139
Element (2,2): Row [4,5,6] ยท Column [8,10,12]
= (4ร8) + (5ร10) + (6ร12) = 32 + 50 + 72 = 154
Result:
[58, 64]
[139, 154]
Common Mistakes That Waste Time
- Forgetting to check dimensions first and getting stuck partway through
- Multiplying corresponding elements directly instead of using dot products
- Assuming A ร B = B ร A
- Misaligning rows and columns when filling in the result grid
- Rushing the addition step and getting wrong sums
Where This Actually Shows Up
Matrix multiplication isn't just a textbook exercise. It's used everywhere in applied math and computer science.
- Computer graphics โ rotating, scaling, and translating images uses matrix multiplication
- Machine learning โ neural networks are essentially layers of matrix multiplications
- Search engines โ PageRank uses matrix operations to rank web pages
- Physics simulations โ transformations in 3D space rely on matrices
- Economics โ input-output models use matrices to describe how industries interact
Tool Comparison for Matrix Operations
| Tool | Best For | Learning Value | Speed |
|---|---|---|---|
| Pen and paper | Small matrices, understanding the process | High | Slow |
| NumPy (Python) | Large matrices, real applications | Medium | Fast |
| MATLAB | Engineering and scientific work | Medium | Fast |
| Online calculators | Quick checks, verifying answers | Low | Instant |
| Octave | Free MATLAB alternative | Medium | Fast |
Getting Started: Your First Practice Problems
Don't touch a calculator yet. Do these by hand.
Problem 1
Multiply [1, 2] ร [[3, 4], [5, 6]]
Answer: [(1ร3 + 2ร5), (1ร4 + 2ร6)] = [13, 16]
Problem 2
Multiply [[2, 0], [1, 3]] ร [[1, 1], [2, 1]]
Answer:
[(2ร1 + 0ร2), (2ร1 + 0ร1)] = [2, 2]
[(1ร1 + 3ร2), (1ร1 + 3ร1)] = [7, 4]
Result: [[2, 2], [7, 4]]
Problem 3
Identify why [[1, 2], [3, 4]] ร [[1, 2]] fails.
Left matrix is 2ร2. Right matrix is 2ร1. The inner dimensions are 2 and 2 โ they match, so this should work. Wait, check again. Yes, it works. Result is 2ร1.
Try [[1, 2, 3]] ร [[1, 2], [3, 4]]. Left is 1ร3, right is 2ร2. 3 โ 2. Can't multiply. That's the one that fails.
The Bottom Line
Matrix multiplication comes down to one thing: dot products. Check your dimensions first, compute each dot product carefully, and fill in the grid. That's it. The rest is practice.
Once you can do 2ร2 and 3ร3 matrices reliably by hand, move to code. NumPy handles the mechanics so you can focus on when and why to use matrix operations, not just how to add up a row of numbers.