Matrix Multiplication — Definition, Formula & Examples
Matrix Multiplication
Matrices are multiplied by the system shown below. Matrices may not be multiplied unless their dimensions are compatible. Note: When an a × b matrix is multiplied times a b × c matrix, the product has dimensions a × c.
![Example: [1 2; 3 4] × [5 6 7; 8 9 10] = [21 24 27; 47 54 61], showing step-by-step matrix multiplication calculations.](/m/m_assets/m16.gif)
Key Formula
Cij=k=1∑nAik⋅Bkj
Where:
- A = The first matrix, with dimensions m × n
- B = The second matrix, with dimensions n × p
- C = The resulting product matrix, with dimensions m × p
- Cij = The entry in row i and column j of the product matrix
- n = The number of columns in A (which must equal the number of rows in B)
Worked Example
Problem: Multiply matrix A (2×3) by matrix B (3×2), where A = [[1, 2, 3], [4, 5, 6]] and B = [[7, 8], [9, 10], [11, 12]].
Step 1: Check that the matrices are compatible. A is 2×3 and B is 3×2. The inner dimensions both equal 3, so multiplication is defined. The result will be a 2×2 matrix.
A2×3⋅B3×2=C2×2
Step 2: Find entry C₁₁ by taking the dot product of row 1 of A with column 1 of B.
C11=(1)(7)+(2)(9)+(3)(11)=7+18+33=58
Step 3: Find entry C₁₂ by taking the dot product of row 1 of A with column 2 of B.
C12=(1)(8)+(2)(10)+(3)(12)=8+20+36=64
Step 4: Find entry C₂₁ by taking the dot product of row 2 of A with column 1 of B.
C21=(4)(7)+(5)(9)+(6)(11)=28+45+66=139
Step 5: Find entry C₂₂ by taking the dot product of row 2 of A with column 2 of B.
C22=(4)(8)+(5)(10)+(6)(12)=32+50+72=154
Answer: The product is C = [[58, 64], [139, 154]].
Another Example
Problem: Multiply P = [[2, 0], [1, 3]] by Q = [[5, 1], [4, 2]].
Step 1: Both matrices are 2×2, so the product is defined and will also be 2×2.
P2×2⋅Q2×2=R2×2
Step 2: Compute all four entries using row-by-column dot products.
R11=(2)(5)+(0)(4)=10
Step 3: Continue with the remaining entries.
R12=(2)(1)+(0)(2)=2,R21=(1)(5)+(3)(4)=17,R22=(1)(1)+(3)(2)=7
Answer: The product is R = [[10, 2], [17, 7]].
Frequently Asked Questions
Why is matrix multiplication not commutative?
The order matters because each entry depends on pairing rows of the first matrix with columns of the second. Switching the order pairs different rows with different columns, which generally produces different results. In fact, even if A·B is defined, B·A may not be defined at all if the dimensions don't match the other way around.
When can you multiply two matrices together?
You can multiply matrix A by matrix B only when the number of columns in A equals the number of rows in B. For example, a 3×4 matrix can multiply a 4×2 matrix (both share the inner dimension 4), but it cannot multiply a 3×2 matrix.
Matrix Multiplication vs. Scalar Multiplication of a Matrix
Matrix multiplication combines two matrices using row-by-column dot products to produce a new matrix. Scalar multiplication simply multiplies every entry of a single matrix by a number (the scalar). Scalar multiplication is commutative and always defined, while matrix multiplication requires compatible dimensions and is not commutative.
Why It Matters
Matrix multiplication is fundamental to solving systems of linear equations, which arise throughout science and engineering. Computer graphics rely on multiplying matrices to rotate, scale, and transform objects on screen. Machine learning algorithms use massive matrix multiplications as their core computational step, making this operation one of the most widely used in modern technology.
Common Mistakes
Mistake: Multiplying corresponding entries element-by-element, as you would with addition.
Correction: Matrix multiplication uses dot products of rows and columns, not element-wise multiplication. You must pair each row of the first matrix with each column of the second.
Mistake: Assuming that A·B equals B·A (treating multiplication as commutative).
Correction: Matrix multiplication is not commutative. Always pay attention to the order: A·B and B·A are generally different matrices, and one product may not even be defined.
Related Terms
- Matrix — The fundamental object being multiplied
- Dimensions — Row and column counts that determine compatibility
- Compatible Matrices — Condition required for multiplication to be defined
- Identity Matrix — Acts as the multiplicative identity for matrices
- Dot Product — The row-by-column operation used in each entry
- Inverse of a Matrix — Matrix that undoes multiplication, like a reciprocal
- Scalar — A single number, contrasted with matrix operands
