What is Matrix Multiplication?
Matrix multiplication is a binary operation that produces a new matrix from two input matrices. For the product AB to be defined, the number of columns in A must equal the number of rows in B. If A is an m×n matrix and B is an n×p matrix, the resulting matrix C = AB is an m×p matrix.
Each element C[i][j] is computed as the dot product of the i-th row of A and the j-th column of B.
How Matrix Multiplication Works
The Dot Product Method
- Take row i of matrix A.
- Take column j of matrix B.
- Multiply corresponding elements and sum the products.
- The result is element C[i][j].
- Repeat for every combination of rows from A and columns from B.
Key Properties
Not Commutative
In general, AB does not equal BA. Order matters.
Associative
Grouping does not affect the result.
Distributive
Multiplication distributes over addition.
Identity
The identity matrix leaves any matrix unchanged.
Applications
Matrix multiplication is essential in computer graphics (transformations, rotations, projections), machine learning (neural network forward passes), physics (quantum mechanics, relativity), economics (input-output models), and engineering (systems of differential equations). It is one of the most important operations in computational mathematics.
Common Pitfalls
- Always verify that the inner dimensions match: columns of A must equal rows of B.
- Remember that matrix multiplication is not commutative.
- The result dimensions are: rows of A by columns of B.
- Each element requires n multiplications and (n-1) additions, where n is the shared dimension.