Linear Algebra

Step-by-Step Matrix Multiplication (2x2, 3x3) Explained

A clear and simple guide to multiplying matrices, including 2x2 and 3x3 examples.

5 min read
By MathlyAI Team
Linear AlgebraMatricesMatrix MultiplicationBeginnerMathematics

Matrix multiplication is a fundamental operation in linear algebra, widely used in computer graphics, physics, engineering, and data science. Unlike regular number multiplication, matrix multiplication has specific rules and is not commutative (meaning A×BA \times B is generally not equal to B×AB \times A).

This guide will break down the process step-by-step, covering both 2x2 and 3x3 matrices.

When Can You Multiply Matrices? (Dimension Compatibility)

Before you can multiply two matrices, say matrix AA and matrix BB (to get ABAB), their dimensions must be compatible.

If matrix AA has dimensions (m×n)(m \times n) (read as "m rows by n columns") and matrix BB has dimensions (n×p)(n \times p), then:

  1. The number of columns in the first matrix (AA) must be equal to the number of rows in the second matrix (BB).
  2. The resulting product matrix ABAB will have dimensions (m×p)(m \times p).

In simple terms: (m×n)×(n×p)=(m×p)(m \times \underline{n}) \times (\underline{n} \times p) = (m \times p).

Example:

  • If AA is 2×32 \times 3 and BB is 3×43 \times 4, then ABAB is 2×42 \times 4.
  • If AA is 2×22 \times 2 and BB is 3×23 \times 2, you cannot multiply ABAB because the inner dimensions (22 and 33) do not match.

How to Multiply Matrices: The "Row by Column" Rule

To find an element in the product matrix C=ABC = AB, you take the dot product of a row from the first matrix (AA) and a column from the second matrix (BB).

Specifically, the element in row ii and column jj of the product matrix CC (denoted as cijc_{ij}) is found by:

  1. Taking the ii-th row of matrix AA.
  2. Taking the jj-th column of matrix BB.
  3. Multiplying the corresponding elements from the row and the column.
  4. Summing these products.

Let's illustrate with examples.

Example 1: 2x2 Matrix Multiplication

Let A=(abcd)A = \begin{pmatrix} a & b \\ c & d \end{pmatrix} and B=(efgh)B = \begin{pmatrix} e & f \\ g & h \end{pmatrix}. The product C=ABC = AB will be a 2×22 \times 2 matrix.

Let's use specific numbers: A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, B=(5678)B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}

We want to find C=(c11c12c21c22)C = \begin{pmatrix} c_{11} & c_{12} \\ c_{21} & c_{22} \end{pmatrix}.

Step 1: Calculate c11c_{11} (Row 1 of A ×\times Column 1 of B) c11=(1×5)+(2×7)=5+14=19c_{11} = (1 \times 5) + (2 \times 7) = 5 + 14 = 19

Step 2: Calculate c12c_{12} (Row 1 of A ×\times Column 2 of B) c12=(1×6)+(2×8)=6+16=22c_{12} = (1 \times 6) + (2 \times 8) = 6 + 16 = 22

Step 3: Calculate c21c_{21} (Row 2 of A ×\times Column 1 of B) c21=(3×5)+(4×7)=15+28=43c_{21} = (3 \times 5) + (4 \times 7) = 15 + 28 = 43

Step 4: Calculate c22c_{22} (Row 2 of A ×\times Column 2 of B) c22=(3×6)+(4×8)=18+32=50c_{22} = (3 \times 6) + (4 \times 8) = 18 + 32 = 50

So, the product matrix CC is: C=(19224350)C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}

Example 2: 3x3 Matrix Multiplication

Let A=(123456789)A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} and B=(987654321)B = \begin{pmatrix} 9 & 8 & 7 \\ 6 & 5 & 4 \\ 3 & 2 & 1 \end{pmatrix}. The product C=ABC = AB will be a 3×33 \times 3 matrix.

We need to calculate 9 elements for CC. Let's go through a few.

Step 1: Calculate c11c_{11} (Row 1 of A ×\times Column 1 of B) c11=(1×9)+(2×6)+(3×3)=9+12+9=30c_{11} = (1 \times 9) + (2 \times 6) + (3 \times 3) = 9 + 12 + 9 = 30

Step 2: Calculate c12c_{12} (Row 1 of A ×\times Column 2 of B) c12=(1×8)+(2×5)+(3×2)=8+10+6=24c_{12} = (1 \times 8) + (2 \times 5) + (3 \times 2) = 8 + 10 + 6 = 24

Step 3: Calculate c13c_{13} (Row 1 of A ×\times Column 3 of B) c13=(1×7)+(2×4)+(3×1)=7+8+3=18c_{13} = (1 \times 7) + (2 \times 4) + (3 \times 1) = 7 + 8 + 3 = 18

...and so on for all 9 elements.

Let's just show the full calculation for one more, c21c_{21}:

Step 4: Calculate c21c_{21} (Row 2 of A ×\times Column 1 of B) c21=(4×9)+(5×6)+(6×3)=36+30+18=84c_{21} = (4 \times 9) + (5 \times 6) + (6 \times 3) = 36 + 30 + 18 = 84

After calculating all elements, the product matrix CC is:

30 & 24 & 18 \\ 84 & 69 & 54 \\ 138 & 114 & 90 \end{pmatrix}$$ ## Properties of Matrix Multiplication - **Not Commutative:** In general, $AB \neq BA$. You might even be able to compute $AB$ but not $BA$ if dimensions don't match for the reverse order. - **Associative:** $(AB)C = A(BC)$. This means the order of operations for multiple multiplications doesn't matter for grouping. - **Distributive:** $A(B + C) = AB + AC$ and $(A + B)C = AC + BC$. - **Identity Matrix:** There is an identity matrix, $I$, such that $AI = IA = A$. For $n \times n$ matrices, $I$ is an $n \times n$ matrix with ones on the main diagonal and zeros elsewhere. ## Common Mistakes - **Incorrect Dimensions:** Always check if the inner dimensions match before attempting to multiply. - **Element-wise Multiplication:** Do not multiply matrices by simply multiplying corresponding elements (that's a different operation called the Hadamard product). - **Order Matters:** Remember that $AB \neq BA$ in most cases. - **Calculation Errors:** Matrix multiplication involves a lot of arithmetic. Double-check your additions and multiplications! ## Conclusion Matrix multiplication, while initially seeming complex, becomes straightforward with practice. The key is to consistently apply the "row by column" rule, ensuring your matrix dimensions are compatible. Master this operation, and you'll unlock a powerful tool for solving problems in various scientific and engineering disciplines.