Matrix multiplication — conditions, process, non-commutativity
Overview
Matrix multiplication is not element-wise multiplication. It's a composition of linear transformations, where each entry in the product is a dot product of a row and column. This operation has strict dimension requirements and, critically, order matters.
[!intuition] Why Matrix Multiplication Works This Way
Think of matrices as transformation machines. When you multiply , you're asking: "What happens if I first apply transformation , then transformation ?"
WHY this definition? Because it preserves the composition of functions. If transforms vector into , and transforms that result into , we want a single matrix such that .
The row-column dot product emerges because:
- Each column of tells you where a basis vector goes
- Each row of tells you how to combine those transformed vectors
- The entry of is "how much of the -th column of contributes to the -th row of 's output"
[!definition] Matrix Multiplication
For matrices and , the product is defined if and only if the ==number of columns in equals the number of rows in ==.
The resulting matrix has dimensions , where:
In words: The entry of is the ==dot product of the -th row of with the -th column of ==.
[!formula] Step-by-Step Process
Condition Check:
The inner dimensions (both ) must match. The outer dimensions ( and ) give the result's shape.
Computation:
For each entry :
- Take row of :
- Take column of :
- Compute:
WHY this works: Each term represents "how much of the -th intermediate dimension contributes through 's row and 's column."
[!example] Example 1 — Valid Multiplication
Check: is , is → inner dimensions match ✓
Result: will be
Compute (row 1 of · column 1 of ):
Why this step? We're summing contributions from each of the 3 intermediate dimensions.
Compute (row 1 of · column 2 of ):
Compute (row 2 of · column 1 of ):
Compute (row 2 of · column 2 of ):
Final result:
[!example] Example 2 — Demonstrating Non-Commutativity
Compute :
Compute :
Result: ✓
WHY? Because composition of transformations depends on order. Rotating then scaling is different from scaling then rotating.
[!example] Example 3 — Undefined Multiplication
Check: is , is → inner dimensions DON'T match (2 ≠ 3) ✗
Result: is undefined. You cannot multiply these matrices.
Why? There's a dimensional mismatch—'s rows expect 2 components, but provides 3.
[!mistake] Common Mistakes
Mistake 1: Thinking
Why it feels right: Regular multiplication of numbers is commutative, so students assume matrices work the same way.
The fix: Matrices represent transformations, and order matters in transformations. Putting on socks then shoes≠ putting on shoes then socks. Even when both and are defined (square matrices of same size), they're usually different.
Verification: Always compute both and compare. Special cases exist (like or diagonal matrices with same diagonal), but they're exceptions.
Mistake 2: Multiplying wrong dimensions
Why it feels right: Students focus on "both are matrices" and forget the column-row matching rule.
The fix: Always write dimensions explicitly: . The red numbers must match. If they don't, stop—multiplication is undefined.
Mistake 3: Element-wise multiplication
Why it feels right: It seems simpler to just multiply (called Hadamard product, notation ).
The fix: Matrix multiplication is row-column dot products, not entry-by-entry. The Hadamard product is a different operation entirely and requires same dimensions. Standard multiplication requires the column-row match.
[!recall]- Feynman Explanation (ELI12)
Imagine you have a list of recipes (matrix ) that tells you how to make smoothies. Each recipe says "use 2 banas, 1 apple, 3 strawberries."
Now you have a price list (matrix ) that tells you the cost per fruit in different stores.
When you multiply , you're answering: "What's the total cost of each smoothie recipe in each store?"
To find the cost of smoothie #1 in store #1, you:
- Take store #1's prices (row 1 of )
- Take smoothie #1's recipe (column 1 of )
- Multiply each price by how many of that fruit you need
- Add them all up
That's one entry in your answer matrix!
Why can't you flip the order? Because "store prices × smoothie recipes" makes sense, but "smoothie recipes × store prices" doesn't—you can't multiply "2 bananas" by "$3 per apple" in a meaningful way. The inner numbers have to represent the same thing (fruits, in this case).
[!mnemonic] Memory Hook
"Columns meet Rows to make Entries"
- Columns of first matrix
- Rows of second matrix
- Must have same count
- Each pair makes an Entry via dot product
Alternatively: "ColRow →RowCol flips the result"
because you're composing transformations in opposite order.
Properties of Matrix Multiplication
- Associative: ✓
- Distributive: ✓
- NOT Commutative: in general ✗
- Identity: where is the identity matrix ✓
- Zero property: where is the zero matrix ✓
WHY associative? Because function composition is associative: .
Connections
- Matrix addition and scalar multiplication — simpler operations with same dimensions
- Identity matrix — the multiplicative "1" for matrices
- Inverse of a matrix — solving to find
- Determinants — (comutativity holds for determinants!)
- Linear transformations — matrices as function representations
- Matrix transpose properties — (order reverses!)
- System of linear equations — uses matrix-vector multiplication
Flashcards
What is the dimension requirement for multiplying and ? :: The number of columns in must equal the number of rows in , i.e., . Result is .
What is the formula for entry in ?
Is matrix multiplication commutative?
If is and is , what are the dimensions of ?
Can you compute if is defined?
Why is matrix multiplication defined as row-column dot products?
Give an example where is defined but is not.
What's the difference between matrix multiplication and Hadamard product?
If and are both , is guaranteed?
What is equal to?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho beta, matrix multiplication ka core idea ye hai ki ye koi element-wise multiplication nahi hai — jaise normal number multiply karte ho waisa nahi. Matrix ko ek "transformation machine" ki tarah socho. Jab tum multiply karte ho, matlab pehle wali transformation apply hoti hai, phir uske upar wali. Isiliye har entry ek row aur column ka dot product hota hai — row of ko column of ke saath multiply karke sum kar dete ho. Ye definition isliye aisi hai kyunki ye function composition ko preserve karti hai, yaani ekdum sahi baith jaye.
Ab ek important condition yaad rakhna: multiplication tabhi possible hai jab ke columns ki sankhya ke rows ke barabar ho. Yaani aur — beech wale dono match karne chahiye, aur result size ka aata hai. Agar inner dimensions match nahi karte, to multiplication undefined ho jata hai, ho hi nahi sakti. Isiliye multiply karne se pehle hamesha dimension check karo, warna galti pakki.
Sabse critical baat jo exam mein bhi aati hai — matrix multiplication commutative nahi hoti, matlab zyadatar cases mein. Kyun? Kyunki order matter karta hai — pehle rotate karke phir scale karna alag hai, aur pehle scale karke phir rotate karna alag. Ye baat normal numbers se bilkul ulti hai jahan hota hai. To yahi teen cheezein — dimension condition, row-column dot product process, aur non-commutativity — yahi matrix multiplication ka poora foundation hai, aur aage determinants, inverses sab isi par tike hain.