Matrix Multiplication- Rules, Examples, and Practice Problems
What Is Matrix Multiplication?
Matrix multiplication is an operation that takes two matrices and produces a third matrix. Unlike regular number multiplication, you cannot multiply just any two matrices together. There are strict rules about dimensions, and the process itself is more involved than multiplying numbers side by side.
Once you understand the mechanics, multiplying matrices becomes a mechanical process. The confusion usually comes from mixing up matrix addition (which is element-by-element) with matrix multiplication (which involves dot products). We'll clear that up here.
The Dimension Rule
Before you multiply anything, check this:
Matrix A (m × n) × Matrix B (n × p) = Result (m × p)
The inner dimensions must match. The number of columns in the first matrix must equal the number of rows in the second matrix. If they don't, stop. You cannot multiply those matrices.
Example: A is 2×3 and B is 3×4. You can multiply them because 3 matches 3. The result will be 2×4.
Example: A is 2×3 and B is 2×4. You cannot multiply them because 3 ≠ 2. The inner dimensions don't match.
How to Multiply Two Matrices
Each element in the result matrix is the dot product of a row from the first matrix and a column from the second matrix.
Step-by-Step Process
- Take the first row of the left matrix
- Take the first column of the right matrix
- Multiply matching pairs of numbers and add them up
- That sum goes in position (row 1, column 1) of your result matrix
- Repeat for every row × column combination
A Simple 2×2 Example
Let A = [[2, 3], [4, 1]] and B = [[5, 6], [7, 8]]
To find element (1,1) of the result: multiply row 1 of A by column 1 of B
(2 × 5) + (3 × 7) = 10 + 21 = 31
To find element (1,2): multiply row 1 of A by column 2 of B
(2 × 6) + (3 × 8) = 12 + 24 = 36
To find element (2,1): multiply row 2 of A by column 1 of B
(4 × 5) + (1 × 7) = 20 + 7 = 27
To find element (2,2): multiply row 2 of A by column 2 of B
(4 × 6) + (1 × 8) = 24 + 8 = 32
Result = [[31, 36], [27, 32]]
Matrix Multiplication vs. Element-by-Element Multiplication
Students confuse these two constantly. They are not the same operation.
| Feature | Matrix Multiplication | Element-by-Element (Hadamard) |
|---|---|---|
| Symbol | AB (no special symbol) | A ∘ B or A ⊙ B |
| Rule | Inner dimensions must match | Dimensions must be identical |
| Process | Dot products of rows × columns | Multiply matching positions |
| Commutative? | Usually NO (AB ≠ BA) | YES (A ∘ B = B ∘ A) |
When you see problems like [[1,2],[3,4]] × [[5,6],[7,8]], that's element-by-element multiplication. When you see A × B with different dimensions, that's true matrix multiplication.
Key Properties You Must Know
Matrix Multiplication Is NOT Commutative
AB ≠ BA in most cases. This is the biggest mental hurdle for beginners coming from regular arithmetic, where 3 × 4 = 4 × 3.
With matrices:
- AB might be defined while BA is not defined (dimension mismatch)
- Both might be defined but give different results
- Both might be defined and happen to give the same result (rare coincidence)
Other Important Properties
Associative: (AB)C = A(BC)
Distributive: A(B + C) = AB + AC
Identity: AI = IA = A (when dimensions allow)
Zero matrix: A × 0 = 0 (but careful about dimension rules)
Practice Problems
Problem 1
Multiply: [[1, 2], [3, 4]] × [[5, 6], [7, 8]]
Answer: [[19, 22], [43, 50]]
Check: (1×5 + 2×7) = 19, (1×6 + 2×8) = 22, (3×5 + 4×7) = 43, (3×6 + 4×8) = 50
Problem 2
Multiply: [[2, 1, 3]] × [[4], [5], [6]]
This is a 1×3 times a 3×1. Result is 1×1.
Answer: [[2×4 + 1×5 + 3×6]] = [[8 + 5 + 18]] = [[31]]
Problem 3
Can you multiply A = [[1, 2, 3]] (1×3) and B = [[4, 5], [6, 7]] (2×2)?
Answer: No. 3 ≠ 2. The inner dimensions don't match.
Problem 4
Multiply: [[3, 0], [1, 2]] × [[1, 1], [0, 1]]
Working:
- Element (1,1): (3×1) + (0×0) = 3
- Element (1,2): (3×1) + (0×1) = 3
- Element (2,1): (1×1) + (2×0) = 1
- Element (2,2): (1×1) + (2×1) = 3
Answer: [[3, 3], [1, 3]]
Common Mistakes
- Forgetting to check dimensions first. Always verify the inner dimensions match before starting.
- Multiplying element-by-element when you should be doing dot products. This is the #1 error in matrix multiplication problems.
- Mixing up which row and column to use. The row always comes from the left matrix, the column from the right.
- Assuming commutativity. Calculate AB and BA separately. They're usually different.
- Rushing the arithmetic. One multiplication error ruins the entire element.
How to Get Better
Practice is the only real way to get faster at this. But there's a technique that helps:
Use your finger or cursor to trace the row and column simultaneously. Point to the first element of the row and the first element of the column, multiply them, then move both pointers to the next elements. This physical tracking helps you keep track of where you are in the calculation.
Work through 10-15 problems with varying dimensions. Start with 2×2, then 2×3, then 3×2, then 3×3. By the fifth problem, the process will start feeling automatic.