Matrix Multiplication Fundamentals
From the matrices curriculum
Matrix Multiplication Fundamentals
TL;DR
Matrix multiplication isn't just multiplying corresponding numbers; it's a specific process of row-by-column calculations. You can only multiply matrices if the number of columns in the first matrix matches the number of rows in the second. The result's size is determined by the first matrix's rows and the second matrix's columns.
1. The Mental Model
Think of matrix multiplication as combining information from rows and columns. Each element in the result matrix is a "dot product" – a sum of products – from one row of the first matrix and one column of the second. It's like finding a weighted average for each spot.
2. The Core Material
Matrix multiplication isn't like regular number multiplication where you just multiply items in the same spot. It's a fundamental operation with specific rules.
Compatibility Check: Can You Even Multiply Them?

Photo by https://kaboompics.com/ on Pexels
Before you do anything, you need to check if two matrices, say A and B, can even be multiplied.
If matrix A has dimensions (m x n) (meaning m rows and n columns) and matrix B has dimensions (p x q), you can only multiply them if n equals p. In plain terms, the number of columns in the first matrix MUST equal the number of rows in the second matrix.
If they are compatible, the resulting matrix, C = AB, will have dimensions (m x q). It'll have the same number of rows as the first matrix and the same number of columns as the second.
graph TD
A["Matrix A (m x n)"] --> B["Check n == p?"]
B -- "No" --> D["Cannot Multiply"]
B -- "Yes" --> C["Matrix B (p x q)"]
C --> E["Result Matrix C (m x q)"]
The Calculation: Row by Column

Photo by Pixabay on Pexels
Let's say you have matrix A and matrix B, and you want to find an element in the resulting matrix C. Specifically, if you want to find the element in row i and column j of C, denoted as C_ij, you do the following:
- Take the
i-th row of matrixA. - Take the
j-th column of matrixB. - Multiply the first element of
A's row by the first element ofB's column. - Multiply the second element of
A's row by the second element ofB's column. - Continue this until you've multiplied all corresponding elements.
- Sum up all those products. That sum is
C_ij.
You repeat this process for every position in the new C matrix.
Example: Small Scale Multiplication

Photo by Bernice Chan on Pexels
Let's say:
A = [[1, 2], [3, 4]] (a 2x2 matrix)
B = [[5, 6], [7, 8]] (a 2x2 matrix)
- Compatibility:
Ais 2x2,Bis 2x2. The number of columns inA(2) equals the number of rows inB(2). So, they are compatible. - Resulting size: The result
Cwill be 2x2.
Let's find the elements of C:
-
C_11(first row, first column):- Take row 1 from
A:[1, 2] - Take column 1 from
B:[5, 7] C_11 = (1 * 5) + (2 * 7) = 5 + 14 = 19
- Take row 1 from
-
C_12(first row, second column):- Take row 1 from
A:[1, 2] - Take column 2 from
B:[6, 8] C_12 = (1 * 6) + (2 * 8) = 6 + 16 = 22
- Take row 1 from
-
C_21(second row, first column):- Take row 2 from
A:[3, 4] - Take column 1 from
B:[5, 7] C_21 = (3 * 5) + (4 * 7) = 15 + 28 = 43
- Take row 2 from
-
C_22(second row, second column):- Take row 2 from
A:[3, 4] - Take column 2 from
B:[6, 8] C_22 = (3 * 6) + (4 * 8) = 18 + 32 = 50
- Take row 2 from
So, C = [[19, 22], [43, 50]].
3. Worked Example
Let's multiply a (2x3) matrix by a (3x2) matrix.
A = [[1, 0, 2], [ -1, 3, 1]] (2 rows, 3 columns)
B = [[3, 1], [2, 1], [1, 0]] (3 rows, 2 columns)
Step 1: Check Compatibility
A is 2x3. B is 3x2. The inner numbers match (3 == 3), so they are compatible.
Step 2: Determine Resulting Matrix Size
The outer numbers are 2 and 2, so the result C will be a 2x2 matrix.
Step 3: Calculate Each Element
-
C_11(Row 1 of A, Column 1 of B):
C_11 = (1 * 3) + (0 * 2) + (2 * 1) = 3 + 0 + 2 = 5 -
C_12(Row 1 of A, Column 2 of B):
C_12 = (1 * 1) + (0 * 1) + (2 * 0) = 1 + 0 + 0 = 1 -
C_21(Row 2 of A, Column 1 of B):
C_21 = (-1 * 3) + (3 * 2) + (1 * 1) = -3 + 6 + 1 = 4 -
C_22(Row 2 of A, Column 2 of B):
C_22 = (-1 * 1) + (3 * 1) + (1 * 0) = -1 + 3 + 0 = 2
Step 4: Form the Result Matrix
C = [[5, 1], [4, 2]]
4. Key Takeaways
- Matrix multiplication requires the inner dimensions of the matrices to match:
(m x n) * (n x q). - The resulting matrix will have dimensions determined by the outer numbers:
(m x q). - Each element in the product matrix is found by taking the dot product of a row from the first matrix and a column from the second.
- Order matters!
A * Bis generally not the same asB * A. - A scalar (single number) can multiply a matrix by multiplying every element, but that's not matrix multiplication.
Common mistakes to avoid:
- Trying to multiply matrices with incompatible dimensions.
- Multiplying element-by-element instead of row-by-column.
- Assuming AB is the same as BA (it's often not, and sometimes BA isn't even possible).
- Getting mixed up with the indices – always row i of the first, column j of the second.
5. Now Try It
Given matrices P = [[2, 1], [0, 3]] and Q = [[4, 0], [1, 5]], calculate PQ. What does your final 2x2 matrix look like?
Frequently asked about Matrix Multiplication Fundamentals
Study this next
Get the full matrices curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Create Free Account