How Matrix Multiplication Works
Matrix multiplication combines two matrices, A and B, into a new matrix C = AB. Unlike adding matrices, you cannot just multiply entries in the same position — the product is only defined when the number of columns in A equals the number of rows in B. If A is an m×n matrix and B is an n×p matrix, the product C is an m×p matrix, and every entry of C is a dot product of a row from A and a column from B.
The formula and method
Each entry of the product is given by C[i,j] = A[i,1]·B[1,j] + A[i,2]·B[2,j] + ... + A[i,n]·B[n,j], written compactly as C[i,j] = Σₖ A[i,k]·B[k,j]. In words: to get the entry in row i, column j of the result, walk along row i of A and down column j of B at the same time, multiply the paired values, and add them up. For example, multiplying a 2×2 matrix A = [[1,2],[3,4]] by B = [[5,6],[7,8]] gives C[1,1] = 1×5 + 2×7 = 19, C[1,2] = 1×6 + 2×8 = 22, C[2,1] = 3×5 + 4×7 = 43, and C[2,2] = 3×6 + 4×8 = 50, so C = [[19,22],[43,50]].
Common mistakes
- Ignoring the dimension rule: multiplication AB is undefined unless columns(A) = rows(B); a 2×3 matrix can multiply a 3×2 matrix, but not another 2×3 matrix.
- Assuming commutativity: in general AB ≠ BA — matrix order matters, and reversing the order can change the result or make the product undefined entirely.
- Confusing it with entrywise multiplication: matrix multiplication is not the same as multiplying corresponding entries (the Hadamard product); it uses row-by-column dot products instead.
Real-world applications
- Computer graphics use matrix multiplication to rotate, scale, and translate 2D and 3D objects by chaining transformation matrices.
- Systems of linear equations can be written and solved as Ax = b, where matrix multiplication maps an input vector x to an output vector b.
- Neural networks compute each layer's output by multiplying an input vector or matrix by a weight matrix, then applying an activation function.
- Markov chains multiply a state vector by a transition matrix repeatedly to project how probabilities evolve over time.