Linear Algebra

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

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

7 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 calculate one element from the second row to make the pattern clear.

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

Using the same row-by-column process, we compute the remaining elements:

  • c22=(4×8)+(5×5)+(6×2)=32+25+12=69c_{22} = (4 \times 8) + (5 \times 5) + (6 \times 2) = 32 + 25 + 12 = 69
  • c23=(4×7)+(5×4)+(6×1)=28+20+6=54c_{23} = (4 \times 7) + (5 \times 4) + (6 \times 1) = 28 + 20 + 6 = 54
  • c31=(7×9)+(8×6)+(9×3)=63+48+27=138c_{31} = (7 \times 9) + (8 \times 6) + (9 \times 3) = 63 + 48 + 27 = 138
  • c32=(7×8)+(8×5)+(9×2)=56+40+18=114c_{32} = (7 \times 8) + (8 \times 5) + (9 \times 2) = 56 + 40 + 18 = 114
  • c33=(7×7)+(8×4)+(9×1)=49+32+9=90c_{33} = (7 \times 7) + (8 \times 4) + (9 \times 1) = 49 + 32 + 9 = 90

After calculating all elements, the product matrix CC is:

C=(30241884695413811490)C = \begin{pmatrix} 30 & 24 & 18 \\ 84 & 69 & 54 \\ 138 & 114 & 90 \end{pmatrix}

Properties of Matrix Multiplication

Matrix multiplication follows several important rules that are useful both theoretically and in practice.

  • Not Commutative:
    In general,

    ABBAAB \neq BA

    Even when both products are defined, they often produce different results. In some cases, one product may exist while the other does not due to incompatible dimensions.

  • Associative:

    (AB)C=A(BC)(AB)C = A(BC)

    This means that when multiplying three matrices, the grouping does not affect the final result (as long as all products are defined).

  • Distributive:

    A(B+C)=AB+ACA(B + C) = AB + AC (A+B)C=AC+BC(A + B)C = AC + BC

    Matrix multiplication distributes over matrix addition.

  • Identity Matrix:
    There exists an identity matrix II such that:

    AI=IA=AAI = IA = A

    For an n×nn \times n matrix, the identity matrix is an n×nn \times n matrix with ones on the main diagonal and zeros elsewhere.


Common Mistakes to Avoid

Matrix multiplication errors are very common, especially for beginners. Watch out for these pitfalls:

  • Ignoring Dimensions:
    Always check that the number of columns in the first matrix equals the number of rows in the second matrix.

  • Element-Wise Multiplication:
    Matrix multiplication is not done by multiplying corresponding elements directly. That operation is called the Hadamard product and is different from standard matrix multiplication.

  • Forgetting Order Matters:
    Even if both ABAB and BABA exist, they are usually not equal.

  • Arithmetic Errors:
    Because each entry involves multiple multiplications and additions, small arithmetic mistakes can easily occur. Double-check your calculations.


Why Matrix Multiplication Matters

Matrix multiplication is more than a classroom exercise. It appears in many real-world applications:

  • Computer Graphics: Transforming and rotating objects in 2D and 3D space.
  • Physics: Describing systems of equations and physical transformations.
  • Engineering: Modeling networks, signals, and control systems.
  • Data Science & Machine Learning: Linear transformations, neural networks, and optimization algorithms.

Understanding how matrix multiplication works gives you access to powerful tools across science and technology.


Key Takeaways

  • Matrix multiplication follows the row-by-column rule.
  • Dimensions must be compatible: (m×n)(n×p)=(m×p)(m \times n)(n \times p) = (m \times p).
  • The operation is not commutative, but it is associative and distributive.
  • Careful, step-by-step calculation prevents most mistakes.
  • With practice, matrix multiplication becomes mechanical and intuitive.

Conclusion

Matrix multiplication may look intimidating at first, but it becomes straightforward once you understand the pattern. By carefully applying the row-by-column rule and checking dimensions, you can confidently multiply both 2×22 \times 2 and 3×33 \times 3 matrices.

Mastering this operation is a crucial step in linear algebra and opens the door to many advanced topics and real-world applications.