How to Solve Matrix Multiplication: Step-by-Step
Subject Mastery

How to Solve Matrix Multiplication: Step-by-Step

By Jonas30 June 202612 min read
Key Takeaways
Matrix multiplication follows the row-by-column rule: each entry in the result is the dot product of one row from the first matrix and one column from the second.
Before multiplying, always check dimensions. If matrix A is m x n and matrix B is n x p, the result is m x p. If the inner dimensions do not match, the multiplication is undefined.
Order matters. AB and BA are generally not equal, and in many cases only one of the two orders is even defined.
The most common error is skipping the dimensions check, which produces wrong-sized results or nonsense entries that are hard to spot without it.
Worked examples below show every step for a 2x2 and a 2x3 times 3x2 multiplication, with the complete arithmetic laid out.

Matrix multiplication follows a specific row-by-column rule, and once you see it clearly, every problem reduces to the same four steps: check dimensions, set up the result grid, compute each entry as a dot product, and verify. Building Classeva's linear algebra practice engine, I noticed the same pattern across hundreds of student submissions: the rule itself rarely confuses people, but skipping the dimensions check produces answers that look plausible and are completely wrong. This walkthrough shows both the method and two fully worked examples so you can follow each step before practicing on your own.

What Is Matrix Multiplication?

Matrix multiplication combines two matrices to produce a third matrix, where each entry in the result summarizes a relationship between an entire row of the first matrix and an entire column of the second. It is not the same as multiplying corresponding elements together. The result depends on how rows and columns interact across the two matrices, which gives linear algebra its power to represent transformations, systems of equations, and data relationships compactly.

The operation appears throughout engineering, data science, and applied mathematics precisely because it encodes the composition of two linear transformations in a single step. When you compute the product of two matrices, you are asking: if transformation B acts on a vector first and transformation A acts on the result, what single transformation does the same job? The answer is AB. That geometric insight, found in any introductory linear algebra course, explains why the row-by-column rule takes the form it does rather than being an arbitrary convention.

The Row-by-Column Rule

The entry at position (i, j) in the result matrix equals the dot product of row i from the first matrix and column j from the second matrix. To compute a dot product, you multiply the first element of the row by the first element of the column, the second by the second, and so on through all matching pairs, then add up all those products. A single entry in a 2x2 result requires two multiplications and one addition. A single entry in a 3x3 result requires three multiplications and two additions.

The row-by-column pattern means that every entry in the result depends on the entire row from the first matrix and the entire column from the second. Change any single number in row 1 of A and every entry in row 1 of the result changes. Change any single number in column 2 of B and every entry in column 2 of the result changes. This coupling is what makes matrix multiplication a rich operation rather than a simple grid of independent calculations.

The Row-by-Column Rule for Matrix MultiplicationRow 1 from matrix A (highlighted in green) and column 1 from matrix B (highlighted in amber) are shown combining through element-wise multiplication and summation to produce the (1,1) entry of result matrix C, which then glows to indicate completion.The Row-by-Column RuleAa11a12a21a22a31a32[]×Bb11b12b21b22b31b32[]=Cc11c12c21c22c31c32[]c11= a11× b11+ a12× b21(row 1 of A) · (column 1 of B) = entry (1,1) of C
Row 1 of A (green) and column 1 of B (amber) combine via dot product to produce entry (1,1) of C (magenta). Repeat for every row-column pair.

The Dimensions Check You Must Do First

Matrix multiplication is only defined when the number of columns in the first matrix matches the number of rows in the second matrix. If matrix A has dimensions m x n and matrix B has dimensions n x p, then AB exists and has dimensions m x p. If the inner pair (both n) does not match, the multiplication is undefined. No amount of arithmetic will save you from a dimensions mismatch.

Matrix A size2 x 3
Matrix B size3 x 4
Inner pair matches?Yes (3 = 3)
Result size2 x 4
Matrix A size3 x 2
Matrix B size2 x 5
Inner pair matches?Yes (2 = 2)
Result size3 x 5
Matrix A size2 x 2
Matrix B size2 x 2
Inner pair matches?Yes (2 = 2)
Result size2 x 2
Matrix A size4 x 3
Matrix B size2 x 3
Inner pair matches?No (3 ≠ 2)
Result sizeUndefined
Matrix A size1 x 4
Matrix B size4 x 1
Inner pair matches?Yes (4 = 4)
Result size1 x 1 (a scalar)

Always write out both sizes and check the inner pair before computing anything.

How to Solve Matrix Multiplication Step by Step

Every matrix multiplication problem follows the same four steps regardless of the size of the matrices. Internalizing the sequence means you never start computing entries before confirming the multiplication is defined, and you never lose track of where you are in a larger calculation. Students who skip straight to arithmetic waste minutes on multiplications that produce a wrong-sized result, which then has to be discarded entirely.

Step 1: Check the Dimensions

Write the dimensions of both matrices as (rows x columns) before touching any numbers. Confirm that the number of columns in the first matrix equals the number of rows in the second matrix. If they match, note the outer dimensions: those give you the size of your answer. If they do not match, stop and re-read the problem. Many errors in linear algebra assignments come from proceeding past a failed dimensions check because the student assumed the problem was well-formed and skipped the verification.

Step 2: Set Up the Result Matrix

Draw an empty grid with the correct number of rows and columns for the result. Label the rows and columns if it helps. For a 2x2 result, you have four entries to fill. For a 3x4 result, you have twelve. Counting the entries before you start prevents you from missing one in the middle of the calculation.

Step 3: Fill Each Entry Using the Dot Product

Work through the result grid systematically: left to right across each row, top row first. For each position (i, j), take row i from the first matrix and column j from the second matrix. Multiply the first elements together, the second elements together, and so on, then sum all products. That sum fills position (i, j) in the result. Do not skip positions or estimate. For a 3x3 result with nine entries, you perform nine separate dot product calculations, each with three multiplications and two additions, which means the total arithmetic is substantial; systematic ordering is what prevents omissions.

Step 4: Verify by Checking All Entries

Count the entries in your result and confirm the total matches the expected size (m rows times p columns). Spot-check one or two entries by recomputing them from scratch. The most reliable check is the bottom-right corner entry: it uses the last row of A and the last column of B, which are the numbers you are most likely to mix up in a long calculation.

1

Check the dimensions

Write (rows x cols) for both matrices. Confirm the inner pair matches. Note the outer pair as your result size.

2

Set up the empty result grid

Draw a blank matrix with the correct dimensions. Count the total entries before filling any.

3

Compute each entry as a dot product

For position (i, j): take row i from A and column j from B, multiply element by element, sum the products.

4

Fill every entry systematically

Work left to right, top to bottom. Do not skip any position.

5

Verify the result

Recompute at least one or two entries independently. Confirm the result has the right dimensions.

Worked Example 1: Multiplying Two 2x2 Matrices

The cleanest starting point is two 2x2 matrices where the dimensions check passes trivially and the result has exactly four entries to fill. This example uses concrete numbers so you can follow every multiplication and addition without ambiguity.

Setting Up the Calculation

Let A and B be the following matrices:

A = [[3, 1], [2, 4]] and B = [[5, 2], [0, 3]]

Dimensions check: A is 2 x 2 and B is 2 x 2. The inner pair is (2, 2), which matches. The result C will be 2 x 2 with four entries to fill. Set up an empty 2 x 2 grid and label the rows and columns before computing anything. The first row of A is [3, 1]. The second row of A is [2, 4]. The first column of B is [5, 0]. The second column of B is [2, 3]. Writing these out explicitly now prevents misreading mid-calculation.

2x2 Matrix Multiplication: A times B equals CFour entries of result matrix C are computed in sequence. Each entry highlights the relevant row from A and column from B, shows the arithmetic, then reveals the answer in the result grid.Example 1: A × BA3124[]×B5203[]=C[]c11= (3)(5) + (1)(0) = 15 + 0 =1515c12= (3)(2) + (1)(3) = 6 + 3 =99c21= (2)(5) + (4)(0) = 10 + 0 =1010c22= (2)(2) + (4)(3) = 4 + 12 =1616Result: C = [[15, 9], [10, 16]]
Each entry of C appears as its row-column dot product is computed. The four entries fill in order: (1,1), (1,2), (2,1), (2,2).

Full Solution, Entry by Entry

Here is the complete arithmetic for each of the four entries:

Entry (1,1): Row 1 of A = [3, 1]. Column 1 of B = [5, 0]. Dot product = (3)(5) + (1)(0) = 15 + 0 = 15.

Entry (1,2): Row 1 of A = [3, 1]. Column 2 of B = [2, 3]. Dot product = (3)(2) + (1)(3) = 6 + 3 = 9.

Entry (2,1): Row 2 of A = [2, 4]. Column 1 of B = [5, 0]. Dot product = (2)(5) + (4)(0) = 10 + 0 = 10.

Entry (2,2): Row 2 of A = [2, 4]. Column 2 of B = [2, 3]. Dot product = (2)(2) + (4)(3) = 4 + 12 = 16.

The result is C = [[15, 9], [10, 16]]. Four entries, computed from four dot products, each requiring two multiplications and one addition.

Write the row and column explicitly before computing

Before calculating any entry, write the row from A and the column from B on a scratch line. For entry (2,2): row 2 = [2, 4], column 2 = [2, 3], then compute the dot product. That two-second habit catches the most common error in matrix multiplication: picking the wrong row or column because you are reading from memory instead of from the written matrix.

Worked Example 2: Non-Square Matrix Multiplication (2x3 times 3x2)

Non-square matrices trip up more students than 2x2 examples because the input and output sizes all differ, and it is easy to confuse which dimension belongs where. This example shows how to multiply a 2x3 matrix by a 3x2 matrix, producing a 2x2 result.

Why the Dimensions Work Here

Let P be a 2x3 matrix and Q be a 3x2 matrix. The dimensions check: P has 3 columns, Q has 3 rows, so the inner pair is (3, 3) and they match. The outer pair is (2, 2), so the result PQ will be 2x2. Notice that QP would be a 3x3 matrix (inner pair 2 = 2, outer pair 3 = 3) and would give a completely different answer, which reinforces why order matters.

Use these specific matrices: P = [[1, 2, 3], [4, 0, 1]] and Q = [[2, 1], [0, 3], [5, 2]].

Full Solution with All Six Entries

Wait: the result is 2x2, so there are only four entries. But each dot product now involves three pairs of numbers instead of two, because the row length is 3. Here is the complete calculation:

Entry (1,1): Row 1 of P = [1, 2, 3]. Column 1 of Q = [2, 0, 5]. Dot product = (1)(2) + (2)(0) + (3)(5) = 2 + 0 + 15 = 17.

Entry (1,2): Row 1 of P = [1, 2, 3]. Column 2 of Q = [1, 3, 2]. Dot product = (1)(1) + (2)(3) + (3)(2) = 1 + 6 + 6 = 13.

Entry (2,1): Row 2 of P = [4, 0, 1]. Column 1 of Q = [2, 0, 5]. Dot product = (4)(2) + (0)(0) + (1)(5) = 8 + 0 + 5 = 13.

Entry (2,2): Row 2 of P = [4, 0, 1]. Column 2 of Q = [1, 3, 2]. Dot product = (4)(1) + (0)(3) + (1)(2) = 4 + 0 + 2 = 6.

The result is PQ = [[17, 13], [13, 6]]. Every entry required three multiplications and two additions, and the result has the dimensions you predicted from the outer pair.

Non-Square Matrix Multiplication: P (2x3) times Q (3x2)Matrix P labeled 2x3 and matrix Q labeled 3x2, with the inner pair 3=3 highlighted in amber and the outer pair 2 and 2 highlighted in green to show the result is 2x2. The complete result PQ equals [[17,13],[13,6]] appears below.Example 2: P (2×3) × Q (3×2)P: 2 × 3Q: 3 × 2inner: 3 = 3123401[]×210352[]=1713136[]Inner: 3 = 3(must match)Outer: 2 × 2(result size)PQ = [[17, 13], [13, 6]]: a 2x2 result from a 2x3 times 3x2 multiplication
The inner pair (3 = 3) confirms the multiplication is defined. The outer pair (2 and 2) gives the result size. Note that QP would be defined too but would produce a 3x3 matrix, not a 2x2 one.
The inner = match rule

If matrix A is m × n and matrix B is n × p, write the sizes side by side as (m × n)(n × p). The two n values in the middle must be the same number. When they match, the multiplication is defined and produces an m × p result. When students write both sizes and circle the inner pair, they catch undefined multiplications before wasting time on arithmetic.

The Most Common Mistake in Matrix Multiplication

Two errors account for most wrong answers in matrix multiplication: swapping the order of the matrices, and picking the wrong row or column mid-calculation. Both errors produce results that look plausible because the arithmetic is internally consistent; the mistake is structural, which makes it harder to spot without a systematic check. Neither error signals itself with an obviously impossible number, so the wrong answer passes casual inspection.

Order Matters: AB Does Not Equal BA

Matrix multiplication is not commutative. For the 2x2 example above, AB = [[15, 9], [10, 16]]. Compute BA with the same matrices and you get a different result. Take B = [[5, 2], [0, 3]] as the first matrix and A = [[3, 1], [2, 4]] as the second:

Entry (1,1): row 1 of B = [5, 2], column 1 of A = [3, 2]. Dot product = (5)(3) + (2)(2) = 15 + 4 = 19.

Entry (1,2): row 1 of B = [5, 2], column 2 of A = [1, 4]. Dot product = (5)(1) + (2)(4) = 5 + 8 = 13.

Entry (2,1): row 2 of B = [0, 3], column 1 of A = [3, 2]. Dot product = (0)(3) + (3)(2) = 0 + 6 = 6.

Entry (2,2): row 2 of B = [0, 3], column 2 of A = [1, 4]. Dot product = (0)(1) + (3)(4) = 0 + 12 = 12.

BA = [[19, 13], [6, 12]], which differs from AB = [[15, 9], [10, 16]] in every entry except (1,2). The problem will specify the required order. Respect it.

AB ≠ BA
matrix multiplication is not commutative
Swapping the order produces a different result in almost every case, and in some cases one order is undefined while the other is defined.

Dimension Errors and How to Catch Them

The second common error is reading from the wrong row or column during a long calculation, especially in 3x3 or larger matrices. The fix is procedural, not mathematical: write the specific row and column on a scratch line before computing the dot product, just as the worked examples above show. If you compute from memory on a 3x3 system, you will eventually pick element (2,3) when you meant (2,2), and the error will not announce itself.

Error typeWrong order
What it looks likeCorrect arithmetic but wrong answer
How to catch itRe-read the problem; multiply in the specified order
Error typeWrong row/column
What it looks likeCorrect method but wrong numbers used
How to catch itWrite row and column explicitly before each dot product
Error typeDimensions mismatch
What it looks likeUndefined multiplication attempted
How to catch itDo the dimensions check before any arithmetic
Error typeMissed entry
What it looks likeResult matrix has empty or repeated entries
How to catch itCount total entries needed before starting; fill left-to-right
Error typeSign error
What it looks likeNegative numbers handled incorrectly in the dot product
How to catch itWork each multiplication separately before summing

Most matrix multiplication errors fall into one of these five categories, all preventable with systematic habits.

Key Properties of Matrix Multiplication

Beyond the computation itself, three algebraic properties govern how matrix multiplication behaves. Recognizing them saves you from re-deriving results and catches errors that purely mechanical checking misses. These properties underpin most of the theorems you encounter in a linear algebra course, from eigenvalue decompositions to least-squares solutions, so understanding them as properties, not just isolated facts, carries you through the rest of the subject.

Associativity: (AB)C = A(BC). When multiplying three or more matrices, you can group them in any order and get the same result. This matters for computations: if one grouping produces smaller intermediate matrices, it can reduce the total number of multiplications needed. The OpenStax College Algebra text covers these properties in depth alongside worked examples if you need a free reference.

Distributivity: A(B + C) = AB + AC. Matrix multiplication distributes over addition, just as ordinary multiplication does. This mirrors the algebraic rules you already know and is the basis for many linear algebra proofs. Gilbert Strang's MIT OpenCourseWare 18.06 Linear Algebra course, which is freely available, develops these rules from the ground up in Lectures 1 through 3.

The identity matrix: For any matrix A with compatible dimensions, AI = IA = A, where I is the identity matrix with ones on the diagonal and zeros elsewhere. The identity plays the role of the number 1 in ordinary arithmetic. The formal definition and proof appear in OpenStax Precalculus chapter 11, which is freely accessible online.

The Identity Matrix in Matrix MultiplicationThe 2x2 identity matrix appears with ones on the diagonal and zeros elsewhere. Then A times I and I times A are both shown to produce A unchanged, illustrating that the identity matrix is the multiplicative identity.The Identity MatrixI (2×2)1001[]Ones on diagonal, zeros elsewhereA × I = A3 12 4×1 00 1=3 12 4Multiplying any matrix by I leaves it unchangedProperties: (AB)C = A(BC) (associative) · A(B+C) = AB+AC (distributive) · AI = IA = A (identity)But: AB ≠ BA in general (not commutative)
The identity matrix leaves any compatible matrix unchanged under multiplication. The three core properties (associativity, distributivity, identity) hold for all matrices; commutativity does not.

One practical consequence of the non-commutativity is worth naming explicitly: when a problem states "find AB," it means compute A times B in that order, with A on the left. If you transpose the order, you may still get a defined result (if the dimensions work in both directions), but it will be a different matrix answering a different question. Exam questions on matrix products that specify order are testing whether you know the rule, not just whether you can compute a dot product.

For deeper practice with linear algebra problems and instant step-by-step feedback, use the subject calculators hub. The hub covers a range of linear algebra and calculus tools alongside other subject areas. If you are working through a full module, the university resources hub collects calculators, citation generators, and study guides in one place.

Subject Calculators

Access calculators for linear algebra, calculus, statistics, and more. Get worked solutions alongside your answers.

Open Subject Calculators

Sibling posts in the subject mastery cluster cover related worked-example walkthroughs. If you are working on calculus, how to solve limits step by step follows the same structure as this post. If statistics is the priority, how to solve hypothesis testing walks through the full method with two worked examples. For exam preparation strategy that applies across all these topics, the maths exam revision guide covers the problem-first approach and error log method in detail.

Students often find that the step they miss is not the dot product itself but the transition from understanding the rule to executing it fluently under timed conditions. The active recall study technique post explains why self-testing on worked problems accelerates that transition faster than re-reading solutions, and the spaced repetition guide shows how to schedule practice problems so the method stays accessible for assessments weeks later.

Key Takeaways

  1. Matrix multiplication follows the row-by-column rule: entry (i, j) in the result equals the dot product of row i from the first matrix and column j from the second matrix.
  2. Before computing anything, check the dimensions. If matrix A is m x n and matrix B is n x p, the inner pair (n = n) must match. The result is m x p.
  3. Set up an empty result grid before filling any entries. Count the total entries needed so you do not miss one in a longer calculation.
  4. Write each row and column explicitly on a scratch line before computing the dot product. This prevents the most common error of reading from the wrong position mid-calculation.
  5. Order matters. AB and BA are generally not equal. Always multiply in the order the problem specifies, and note that one order may be defined while the other is not.
  6. Associativity holds: (AB)C = A(BC). Distributivity holds: A(B + C) = AB + AC. The identity matrix I satisfies AI = IA = A. Commutativity does not hold in general.
  7. The most reliable verification is to recompute one or two entries independently, particularly the bottom-right corner, which uses the rows and columns you are most likely to misread.

Related articles

Try a free AI tutoring session