Matrix Multiplication — Rules, Steps & Examples

Understand the rules for multiplying two matrices. Learn the row-column dot product method with step-by-step examples for 2x2 and 3x3 matrices.

Basic Operations

Detailed Explanation

Matrix Multiplication Step by Step

Matrix multiplication is fundamentally different from addition. To compute C = A * B, each element C[i,j] is the dot product of the i-th row of A and the j-th column of B:

C[i,j] = sum(A[i,k] * B[k,j]) for k = 1 to n

Dimension Requirements

For A (m x n) and B (p x q):

  • n must equal p (A's columns must equal B's rows)
  • The result C has dimensions m x q

Example: 2x2 Multiplication

A = | 1  2 |    B = | 5  6 |
    | 3  4 |        | 7  8 |

C[1,1] = 1*5 + 2*7 = 5 + 14 = 19
C[1,2] = 1*6 + 2*8 = 6 + 16 = 22
C[2,1] = 3*5 + 4*7 = 15 + 28 = 43
C[2,2] = 3*6 + 4*8 = 18 + 32 = 50

C = | 19  22 |
    | 43  50 |

Key Properties

  • Not commutative: A * B does not generally equal B * A
  • Associative: (A * B) * C = A * (B * C)
  • Distributive: A * (B + C) = A * B + A * C
  • Identity: A * I = I * A = A

Why Order Matters

Consider a 2x3 matrix A and a 3x4 matrix B. A * B gives a 2x4 matrix, but B * A is undefined since B has 4 columns and A has 2 rows. Even for square matrices, changing the order usually produces different results.

Use Case

Matrix multiplication is central to computer graphics (combining transformation matrices for rotation, scaling, and translation), machine learning (forward passes through neural network layers), and solving systems of linear equations. It is one of the most frequently performed operations in scientific computing.

Try It — Matrix Calculator

Open full tool