On this page
Multiplying matrices isn't like multiplying ordinary numbers. With numbers, 3 × 4 is the same as 4 × 3, and you can always multiply any two numbers together. With matrices, you have to check their dimensions first, and the order in which you multiply them matters immensely.
If you place two incompatible matrices side by side, the calculation simply cannot happen. The rows and columns won't line up, and you'll run out of numbers to pair together.
Here is exactly how to know if two matrices can be multiplied, what size the answer will be, and why swapping the order often breaks the calculation entirely.
When can two matrices be multiplied?
The fundamental rule of matrix multiplication is about compatibility. According to the OpenStax College Algebra textbook, two matrices can be multiplied only if the number of columns in the first matrix is equal to the number of rows in the second matrix.
When you multiply matrices, you calculate the dot product of the first matrix's rows with the second matrix's columns. If a row in matrix A has three elements, you need exactly three elements in the column of matrix B to multiply them against. You multiply the first item of the row by the first item of the column, the second by the second, and the third by the third, then add them up. If the counts do not match, the operation stops before it can even begin because there is a missing partner.
If you are stuck on a calculation that doesn't seem to line up, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
What is the rule for matrix multiplication order?
A matrix's order (or dimension) is written as "rows × columns". A matrix with 2 rows and 3 columns is a 2 × 3 matrix.
To quickly check if matrix A and matrix B can be multiplied to form AB, use this practical framework: write their dimensions side by side on paper.
Write the order of the first matrix (for example, 2 × 3).
Write the order of the second matrix directly next to it (for example, 3 × 4).
Look at the two "inner" numbers where the dimensions touch.
If those two inner numbers match (in this case, 3 and 3), the multiplication is allowed. If they do not match, the product AB is undefined and you cannot proceed.
How do you find the order of the product?
Once you know the multiplication is valid, finding the size of the resulting matrix is straightforward. The OpenStax textbook states that multiplying an m × r matrix by an r × n matrix results in an m × n product matrix.
Using the side-by-side trick:
Matrix A: 2 × 3
Matrix B: 3 × 4
The inner numbers (3 and 3) disappear during the calculation.
The outer numbers (2 and 4) remain.
The product matrix AB will be a 2 × 4 matrix. It inherits the number of rows from the first matrix (2 rows) and the number of columns from the second matrix (4 columns).
For a concrete example, imagine multiplying a 1 × 3 row matrix by a 3 × 1 column matrix. The inner numbers (3 and 3) match. The outer numbers are 1 and 1, so the result is a 1 × 1 matrix (which is just a single number). Conversely, if you multiply a 3 × 1 matrix by a 1 × 3 matrix, the inner numbers are 1 and 1, and the result is a large 3 × 3 matrix.
Why does AB exist when BA does not?
Because the inner dimensions must match, reversing the order of the matrices often breaks the rule. Wikipedia notes that matrix multiplication is generally non-commutative, meaning changing the order of the factors changes the result or makes the product undefined.
Let's try to reverse our previous example to see why:
We know AB works (a 2 × 3 matrix multiplied by a 3 × 4 matrix).
What about BA?
Matrix B is 3 × 4.
Matrix A is 2 × 3.
Put them side by side: 3 × 4 and 2 × 3. The inner numbers are now 4 and 2. They do not match. Therefore, the product BA is completely undefined.
Even when both AB and BA are defined (for example, if both are 2 × 2 square matrices), the actual numbers in the resulting matrices are rarely the same. The fact that AB ≠ BA is a core principle of linear algebra that trips up many students.
To master the underlying theory, you can explore the Fermi Concept Library, where every concept in mathematics has its own lesson and its place in the map.
If you are exploring more linear algebra properties, learn about finding Aⁿ for a matrix by spotting the pattern or how to find the area of a triangle using determinants.



