We don't just statecij=∑kaikbkj. We discover it.
Why the dimensions must match:bj lives in Rn (it has n entries, one
per row of B). For A to eat an n-vector, A must have exactly n columns. That is the entire
reason for the "columns of A = rows of B" rule. It is a plug fits socket condition.
What condition allows AB to exist? → columns of A = rows of B.
Shape of (m×n)(n×p)? → m×p.
Formula for cij? → ∑kaikbkj.
Is matrix mult commutative? → No (in general).
What is (AB)⊤? → B⊤A⊤.
Recall Feynman: explain to a 12-year-old
Imagine two vending machines lined up. The first machine takes 4 coins and spits out 5 snacks.
The second machine takes exactly 5 snacks and spits out 2 drinks. They only connect because the
first's output (5) matches the second's input (5). The combined machine takes 4 coins,
gives 2 drinks — the 5 in the middle "disappears" inside. To find each output, you mix a whole
row of one recipe with a whole column of the other, multiplying pairs and adding them up.
Dekho, matrix multiplication ko samajhne ka sabse easy tarika hai: har matrix ek machine hai jo
vectors ko transform karti hai. Jab hum A×B karte hain, matlab pehle B wali transformation
lagao, phir uske output pe A wali transformation lagao. Isliye rule aata hai — A ke columns
aur B ke rows barabar hone chahiye. Kyun? Kyunki B ka har column ek n-dimension ka vector
hai, aur A ko us n-vector ko "khaana" hai, to A ke paas exactly n columns hone hi chahiye.
Yahi hai "plug fits socket" wali baat.
Shape yaad rakhne ka mantra: "Inners match, outers survive." Agar A hai m×n aur B hai
n×p, to beech wale n aur n match karke gayab ho jaate hain, aur bahar wale m aur p
bach jaate hain — result banta hai m×p. Har ek entry cij nikaalne ke liye A ki i-th
row ko B ki j-th column ke saath dot product karo (pairs multiply karo, phir add karo).
Ek important cheez: matrix multiplication commutative nahi hai, yaani AB aur BA generally
alag hote hain — kabhi to inki shape hi alag hoti hai! Jaise "pehle mozey pehno phir joote" vs "pehle
joote phir mozey" — order matters. Aur ek common galti: matrices ko element-by-element multiply mat
karo (woh Hadamard product hai, alag cheez). Matrix mult hamesha row-column dot product se hota hai.
ML mein yeh core hai bhai — neural network ka har layer y=Wx ek matrix-vector
multiplication hi to hai, aur layers stack karna matrices ko multiply karke compose karna hai. Isliye
dimensionality ka hisaab bilkul solid hona chahiye, warna "shape mismatch" error har jagah aayega.