Matrix Multiplication: Compatibility, Order, and Why AB Need Not Equal BA
Learn when two matrices can be multiplied, how to find the order of the product, and why changing AB to BA can change the answer.
- 12th
- Study Advice
Matrix multiplication becomes much easier when you stop treating it like ordinary multiplication.
With numbers, 3 x 5 and 5 x 3 give the same answer. With matrices, order matters. Sometimes AB is possible but BA is not. Sometimes both are possible, but their answers have different orders. Sometimes both answers have the same order, yet the entries are still different.
That is why matrix multiplication needs a little more respect.
The good news is that the whole topic can be controlled with three questions:
- Can the two matrices be multiplied?
- What will be the order of the product?
- Am I multiplying in the correct order,
ABorBA?
This guide will help you understand compatibility, order, row-column multiplication, and why AB need not equal BA.
First, What Does Order Mean?
The order of a matrix tells you its number of rows and columns.
Order = rows x columns
So a matrix with 2 rows and 3 columns has order 2 x 3.
For example:
A = [ 1 4 6 ]
[ 2 5 8 ]
This matrix has 2 rows and 3 columns.
So:
Order of A = 2 x 3
Another example:
B = [ 7 1 ]
[ 3 0 ]
[ 5 2 ]
This matrix has 3 rows and 2 columns.
So:
Order of B = 3 x 2
Before multiplying any two matrices, always write their orders first. It saves time, avoids wrong attempts, and makes the rest of the question almost mechanical.
The Compatibility Rule
Suppose:
A has order m x n
B has order n x p
Then AB is defined, because the number of columns in A is equal to the number of rows in B.
The product will have order:
AB has order m x p
In a compact form:
(m x n)(n x p) = m x p
Look carefully at what happened:
(m x n)(n x p)
| |
must match
The inside numbers must match.
Then the outside numbers become the order of the answer.
(m x n)(n x p) = m x p
| |
outside numbers become the product order
A Quick Compatibility Table
| Order of A | Order of B | Is AB possible? | Order of AB |
|---|---|---|---|
| 2 x 3 | 3 x 4 | Yes | 2 x 4 |
| 4 x 2 | 2 x 5 | Yes | 4 x 5 |
| 3 x 3 | 3 x 1 | Yes | 3 x 1 |
| 2 x 4 | 3 x 2 | No | Not defined |
| 5 x 1 | 5 x 2 | No | Not defined |
Notice something important: two matrices do not have to be of the same order to be multiplied.
A 2 x 3 matrix can multiply a 3 x 4 matrix.
A 4 x 2 matrix can multiply a 2 x 5 matrix.
The condition is not “same order”.
The condition is:
columns of first matrix = rows of second matrix
Why Same Order Is Not Enough
Many students make this mistake:
“A and B are both 2 x 3, so surely we can multiply them.”
Not necessarily.
If:
A is 2 x 3
B is 2 x 3
Then:
AB = (2 x 3)(2 x 3)
The inside numbers are 3 and 2.
They do not match.
So AB is not defined.
Even though the two matrices have the same order, they cannot be multiplied in this order.
What Matrix Multiplication Actually Does
Once compatibility is confirmed, each entry of the product is found by matching a row of the first matrix with a column of the second matrix.
That is the heart of matrix multiplication:
row of first matrix x column of second matrix
Suppose:
A = [ 1 2 ]
[ 3 4 ]
B = [ 5 6 ]
[ 7 8 ]
Both are 2 x 2, so AB is possible.
The product will also be 2 x 2.
To find the first entry of AB, use row 1 of A and column 1 of B:
1 x 5 + 2 x 7 = 5 + 14 = 19
To find the entry in row 1, column 2, use row 1 of A and column 2 of B:
1 x 6 + 2 x 8 = 6 + 16 = 22
To find the entry in row 2, column 1, use row 2 of A and column 1 of B:
3 x 5 + 4 x 7 = 15 + 28 = 43
To find the entry in row 2, column 2, use row 2 of A and column 2 of B:
3 x 6 + 4 x 8 = 18 + 32 = 50
So:
AB = [ 19 22 ]
[ 43 50 ]
This is why the order of writing matters. In AB, rows come from A and columns come from B. If you reverse the matrices, the rows and columns being paired change.
The Row-Column Method
Here is a clean way to calculate any matrix product.
First write the orders.
Second confirm that the inside numbers match.
Third draw the blank product matrix with the correct order.
Fourth fill each entry by using:
row from first matrix with column from second matrix
For a 2 x 3 matrix multiplied by a 3 x 2 matrix:
(2 x 3)(3 x 2) = 2 x 2
So the answer must have 2 rows and 2 columns.
That means your blank answer should look like this:
AB = [ _ _ ]
[ _ _ ]
Now each blank is filled using one row and one column.
| Entry to find | Use this row | Use this column |
|---|---|---|
| Row 1, column 1 | Row 1 of A | Column 1 of B |
| Row 1, column 2 | Row 1 of A | Column 2 of B |
| Row 2, column 1 | Row 2 of A | Column 1 of B |
| Row 2, column 2 | Row 2 of A | Column 2 of B |
A Complete Rectangular Example
Let:
A = [ 1 2 3 ]
[ 4 0 5 ]
B = [ 2 1 ]
[ 3 4 ]
[ 0 6 ]
First check the order.
A is 2 x 3
B is 3 x 2
So:
AB = (2 x 3)(3 x 2)
The inside numbers match.
Therefore, AB is defined.
The product will have order:
2 x 2
Now calculate:
AB = [ 1 2 3 ] [ 2 1 ]
[ 4 0 5 ] [ 3 4 ]
[ 0 6 ]
Entry in row 1, column 1:
1 x 2 + 2 x 3 + 3 x 0
= 2 + 6 + 0
= 8
Entry in row 1, column 2:
1 x 1 + 2 x 4 + 3 x 6
= 1 + 8 + 18
= 27
Entry in row 2, column 1:
4 x 2 + 0 x 3 + 5 x 0
= 8 + 0 + 0
= 8
Entry in row 2, column 2:
4 x 1 + 0 x 4 + 5 x 6
= 4 + 0 + 30
= 34
So:
AB = [ 8 27 ]
[ 8 34 ]
The most important part is not the arithmetic. The most important part is the discipline:
Check order first.
Then calculate row by column.
Why AB May Be Possible But BA May Not Be Possible
Now let us reverse the idea.
Suppose:
A is 2 x 3
B is 3 x 4
Then:
AB = (2 x 3)(3 x 4)
The inside numbers match, so AB is defined.
The order of AB is:
2 x 4
But what about BA?
BA = (3 x 4)(2 x 3)
The inside numbers are 4 and 2.
They do not match.
So BA is not defined.
This is the first reason AB need not equal BA: sometimes one product exists and the other does not even exist.
Why AB And BA Can Have Different Orders
Now take:
A is 2 x 3
B is 3 x 2
Then:
AB = (2 x 3)(3 x 2) = 2 x 2
So AB is defined and has order 2 x 2.
Now reverse:
BA = (3 x 2)(2 x 3) = 3 x 3
So BA is also defined, but it has order 3 x 3.
Can a 2 x 2 matrix be equal to a 3 x 3 matrix?
No.
They do not even have the same size.
This is the second reason AB need not equal BA: both may exist, but their orders may be different.
Even When Orders Match, AB May Still Differ From BA
Now let us look at the case that surprises students most.
If A and B are both square matrices of the same order, then AB and BA are both defined and have the same order.
But they still need not be equal.
Let:
A = [ 1 2 ]
[ 0 1 ]
B = [ 3 0 ]
[ 4 1 ]
Both A and B are 2 x 2.
So both AB and BA are possible.
First find AB:
AB = [ 1 2 ] [ 3 0 ]
[ 0 1 ] [ 4 1 ]
AB = [ 1 x 3 + 2 x 4 1 x 0 + 2 x 1 ]
[ 0 x 3 + 1 x 4 0 x 0 + 1 x 1 ]
AB = [ 11 2 ]
[ 4 1 ]
Now find BA:
BA = [ 3 0 ] [ 1 2 ]
[ 4 1 ] [ 0 1 ]
BA = [ 3 x 1 + 0 x 0 3 x 2 + 0 x 1 ]
[ 4 x 1 + 1 x 0 4 x 2 + 1 x 1 ]
BA = [ 3 6 ]
[ 4 9 ]
Clearly:
AB != BA
This is not a calculation accident. It happens because the multiplication process has changed.
In AB, rows of A meet columns of B.
In BA, rows of B meet columns of A.
Those are two different pairings.
A Simple Way To Remember Why Order Matters
Think of matrix multiplication as a sequence of actions.
Doing action A and then action B may not give the same result as doing action B and then action A.
For example, imagine folding a paper and then cutting a corner. Now imagine cutting a corner and then folding the paper. The same two actions are involved, but the final result may not match.
Matrix multiplication works in a similar spirit. The order tells you the sequence and the matching. Reversing it is not a harmless swap.
This is why you should never write:
AB = BA
unless the question gives a reason or you have proved it for those particular matrices.
A Business-Style Example
Matrix multiplication is useful because it can combine organised data quickly.
Suppose a small stationery stall sells three items:
- notebooks
- pens
- folders
The quantities sold in two days are:
Q = [ 10 12 ]
[ 20 15 ]
[ 4 6 ]
Here, rows represent items and columns represent days.
So Q is 3 x 2.
Now suppose the prices are:
P = [ 40 10 25 ]
Here, P is 1 x 3.
To find total sales value for each day, multiply:
PQ = (1 x 3)(3 x 2) = 1 x 2
This works because the three prices match the three item rows.
Now calculate:
PQ = [ 40 10 25 ] [ 10 12 ]
[ 20 15 ]
[ 4 6 ]
For day 1:
40 x 10 + 10 x 20 + 25 x 4
= 400 + 200 + 100
= 700
For day 2:
40 x 12 + 10 x 15 + 25 x 6
= 480 + 150 + 150
= 780
So:
PQ = [ 700 780 ]
The answer says total sales value was 700 on day 1 and 780 on day 2.
Now try reversing the order:
QP = (3 x 2)(1 x 3)
The inside numbers are 2 and 1.
They do not match.
So QP is not defined.
The story explains the maths. Prices must match items. If the order breaks that matching, the multiplication has no meaning.
Common Mistakes Students Make
Matrix multiplication is not difficult, but it punishes careless order.
Here are the mistakes to watch for.
| Mistake | Why it is wrong | Better habit |
|---|---|---|
| Multiplying matrices just because they have the same order | Same order is needed for addition, not multiplication | Check inside numbers |
| Writing the wrong order of the answer | The product order comes from outside numbers | Write (m x n)(n x p) = m x p |
| Multiplying row by row | Matrix multiplication uses row with column | Say “row of first, column of second” |
Assuming AB = BA | Matrix multiplication is usually not commutative | Calculate both or use the given condition |
| Forgetting that one product may be undefined | AB possible does not guarantee BA possible | Check both orders separately |
How To Start Any Matrix Multiplication Question
Use this checklist:
Step 1: Write the order of the first matrix.
Step 2: Write the order of the second matrix.
Step 3: Check whether the inside numbers match.
Step 4: Write the order of the product using the outside numbers.
Step 5: Draw the blank product matrix.
Step 6: Fill each entry using row of first matrix and column of second matrix.
For example:
A is 3 x 2
B is 2 x 4
Then:
AB = (3 x 2)(2 x 4) = 3 x 4
Before calculating, your answer must look like:
AB = [ _ _ _ _ ]
[ _ _ _ _ ]
[ _ _ _ _ ]
This blank shape protects you from half the errors in the question.
Practice Questions
Try these without calculating full products unless asked.
Question 1
If A is 4 x 3 and B is 3 x 5, is AB defined? What is its order?
Answer:
AB = (4 x 3)(3 x 5)
The inside numbers match.
So AB is defined.
Order of AB = 4 x 5
Question 2
If A is 2 x 4 and B is 3 x 2, is AB defined?
Answer:
AB = (2 x 4)(3 x 2)
The inside numbers are 4 and 3.
They do not match.
So AB is not defined.
Question 3
If A is 2 x 3 and B is 3 x 2, compare the orders of AB and BA.
Answer:
AB = (2 x 3)(3 x 2) = 2 x 2
BA = (3 x 2)(2 x 3) = 3 x 3
Both products are defined, but their orders are different.
So AB and BA cannot be equal.
Question 4
Find AB:
A = [ 2 1 ]
[ 0 3 ]
B = [ 4 5 ]
[ 6 7 ]
Answer:
AB = [ 2 x 4 + 1 x 6 2 x 5 + 1 x 7 ]
[ 0 x 4 + 3 x 6 0 x 5 + 3 x 7 ]
AB = [ 14 17 ]
[ 18 21 ]
Question 5
For the same A and B in Question 4, is BA the same as AB?
Answer:
BA = [ 4 5 ] [ 2 1 ]
[ 6 7 ] [ 0 3 ]
BA = [ 4 x 2 + 5 x 0 4 x 1 + 5 x 3 ]
[ 6 x 2 + 7 x 0 6 x 1 + 7 x 3 ]
BA = [ 8 19 ]
[ 12 27 ]
So:
AB = [ 14 17 ]
[ 18 21 ]
BA = [ 8 19 ]
[ 12 27 ]
Therefore:
AB != BA
The Best Exam Habit For This Topic
Do not begin by multiplying entries.
Begin by writing the order.
If the question asks for AB, write:
order of A, order of B, order of AB
If the question asks for BA, write:
order of B, order of A, order of BA
This small habit makes your solution clearer and helps you catch undefined products early.
Final Revision Map
Keep this summary in mind:
| Idea | What to remember |
|---|---|
| Order of a matrix | rows x columns |
| Multiplication condition | columns of first = rows of second |
| Product order | rows of first x columns of second |
| Entry calculation | row of first with column of second |
AB and BA | Check separately |
| Main warning | AB need not equal BA |
The topic becomes simple when every question begins with order.
Do not ask, “Can I multiply these matrices?”
Ask more carefully:
Can I multiply them in this order?
That one phrase is the real key.
Frequently Asked Questions
What is the rule for multiplying two matrices?
Two matrices can be multiplied if the number of columns in the first matrix is equal to the number of rows in the second matrix. If A is m x n and B is n x p, then AB is defined and has order m x p.
What is meant by compatibility in matrix multiplication?
Compatibility means the orders are suitable for multiplication. For AB, the columns of A must match the rows of B. If they do not match, AB is not defined.
How do I find the order of AB?
Write the orders side by side. If A is m x n and B is n x p, the inside numbers match and the outside numbers give the order of the answer. So AB has order m x p.
Can two matrices of the same order always be multiplied?
No. Same order is the rule for addition and subtraction, not multiplication. For multiplication, the columns of the first matrix must equal the rows of the second matrix.
Can AB be defined while BA is not defined?
Yes. For example, if A is 2 x 3 and B is 3 x 4, then AB is defined because the inside numbers match. But BA is not defined because (3 x 4)(2 x 3) has inside numbers 4 and 2, which do not match.
If AB and BA are both defined, are they always equal?
No. They may have different orders, or they may have the same order but different entries. Matrix multiplication is usually not commutative.
Why does order matter in matrix multiplication?
Order matters because AB uses rows of A with columns of B, while BA uses rows of B with columns of A. These are different pairings, so the result can change.
What is the easiest way to avoid mistakes in matrix multiplication?
Write the order of each matrix before calculating. Then check the inside numbers. Then draw the blank answer with the correct order. After that, fill entries using row of the first matrix and column of the second matrix.
Is AB ever equal to BA?
Yes, sometimes. Certain special matrices may satisfy AB = BA. But you should never assume it. Unless the question gives a condition or the calculation shows equality, treat AB and BA as different.
Looking for commerce tuitions?
Prachi is a gold-medalist commerce teacher with experience at Deloitte and KPMG. She focuses on fundamentals to build a strong foundation.