How to Multiply Matrices — Step-by-Step
Matrix multiplication (also called the matrix product) combines two matrices to produce a third. Unlike ordinary multiplication, there is an important rule: the number of columns in the first matrix must equal the number of rows in the second matrix.
The Golden Rule: cols(A) = rows(B)
If matrix A is m × n and matrix B is n × p, then A × B produces an m × p matrix. The inner dimensions (both n) must match.
Step-by-step process
- Verify that the number of columns in A equals the number of rows in B.
- The result matrix C will have the same number of rows as A and the same number of columns as B.
- Each element C[i, j] is the dot product of row i from A and column j from B.
- Multiply matching elements, then sum them all up.
Worked example: 2×2 matrix multiplication
Multiply A (2×2) by B (2×2):
Result: C = [[19, 22], [43, 50]]
Worked example: 3×3 matrix multiplication
For a 3×3 example, each element requires the sum of three products — one for each inner dimension. For example, to find C[1,1], take row 1 of A = [a, b, c] and column 1 of B = [d, e, f], then compute a·d + b·e + c·f. Click "Show step-by-step solution" above to see every calculation after using the calculator.
Which Matrix Sizes Can Be Multiplied?
The table below shows common matrix size combinations, whether they are compatible, and what size result they produce:
| Matrix A | Matrix B | Compatible? | Result size |
| 2×2 | 2×2 | Yes | 2×2 |
| 2×3 | 3×2 | Yes | 2×2 |
| 3×3 | 3×3 | Yes | 3×3 |
| 3×2 | 2×4 | Yes | 3×4 |
| 4×4 | 4×4 | Yes | 4×4 |
| 1×3 | 3×1 | Yes | 1×1 (scalar) |
| 2×3 | 2×3 | No | — |
| 3×2 | 3×2 | No | — |
| 4×3 | 2×4 | No | — |
Our calculator checks this automatically and shows a warning if dimensions are incompatible. To multiply a matrix by a vector, set one matrix to a single column (e.g., 3×1).
Key Properties of Matrix Multiplication
Not commutative
Unlike regular multiplication, A × B ≠ B × A in general. Often B × A is not even defined when A × B is. This is the most important distinction when working with matrices.
Associative
(A × B) × C = A × (B × C). When multiplying three matrices, the grouping does not affect the final result. This calculator handles 3-matrix chains in a single step.
Distributive
A × (B + C) = A×B + A×C. Matrix multiplication distributes over addition, just like scalar multiplication.
Identity matrix
Multiplying any matrix A by the identity matrix I returns A unchanged: A × I = I × A = A.
Real-world applications
Matrix multiplication is used in computer graphics (3D coordinate transforms), machine learning (neural network forward passes), economics (Leontief input-output models), network theory (shortest path algorithms), and cryptography (Hill cipher).
Related Matrix Calculators
Need more matrix operations? These tools handle the most common tasks: