2.6.5Matrices & Determinants — Introduction

Matrix multiplication — conditions, process, non-commutativity

2,146 words10 min readdifficulty · medium6 backlinks

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 ABAB, you're asking: "What happens if I first apply transformation BB, then transformation AA?"

WHY this definition? Because it preserves the composition of functions. If BB transforms vector x\vec{x} into BxB\vec{x}, and AA transforms that result into A(Bx)A(B\vec{x}), we want a single matrix C=ABC = AB such that Cx=A(Bx)C\vec{x} = A(B\vec{x}).

The row-column dot product emerges because:

  • Each column of BB tells you where a basis vector goes
  • Each row of AA tells you how to combine those transformed vectors
  • The (i,j)(i,j) entry of ABAB is "how much of the jj-th column of BB contributes to the ii-th row of AA's output"

[!definition] Matrix Multiplication

For matrices Am×nA_{m \times n} and Bn×pB_{n \times p}, the product C=ABC = AB is defined if and only if the ==number of columns in AA equals the number of rows in BB==.

The resulting matrix CC has dimensions m×pm \times p, where:

Cij=k=1nAikBkjC_{ij} = \sum_{k=1}^{n} A_{ik} \cdot B_{kj}

In words: The (i,j)(i,j) entry of CC is the ==dot product of the ii-th row of AA with the jj-th column of BB==.


[!formula] Step-by-Step Process

Condition Check:

Am×n×Bn×p=Cm×pA_{m \times \color{red}n} \times B_{\color{red}n \times p} = C_{m \times p}

The inner dimensions (both nn) must match. The outer dimensions (mm and pp) give the result's shape.

Computation:

For each entry CijC_{ij}:

  1. Take row ii of AA: [Ai1,Ai2,,Ain][A_{i1}, A_{i2}, \ldots, A_{in}]
  2. Take column jj of BB: [B1jB2j Bnj]\begin{bmatrix} B_{1j} \\ B_{2j} \\ \vdots \ B_{nj} \end{bmatrix}
  3. Compute: Cij=Ai1B1j+Ai2B2j++AinBnjC_{ij} = A_{i1}B_{1j} + A_{i2}B_{2j} + \cdots + A_{in}B_{nj}

WHY this works: Each term AikBkjA_{ik}B_{kj} represents "how much of the kk-th intermediate dimension contributes through AA's row and BB's column."


[!example] Example 1 — Valid Multiplication

A=[123456]2×3,B=[789101112]3×2A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}_{2 \times 3}, \quad B = \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{bmatrix}_{3 \times 2}

Check: AA is 2×32 \times \color{red}3, BB is 3×2\color{red}3 \times 2 → inner dimensions match ✓
Result: CC will be 2×22 \times 2

Compute C11C_{11} (row 1 of AA · column 1 of BB):

C11=17+29+311=7+18+33=58C_{11} = 1 \cdot 7 + 2 \cdot 9 + 3 \cdot 11 = 7 + 18 + 33 = 58

Why this step? We're summing contributions from each of the 3 intermediate dimensions.

Compute C12C_{12} (row 1 of AA · column 2 of BB):

C12=18+210+312=8+20+36=64C_{12} = 1 \cdot 8 + 2 \cdot 10 + 3 \cdot 12 = 8 + 20 + 36 = 64

Compute C21C_{21} (row 2 of AA · column 1 of BB):

C21=47+59+611=28+45+66=139C_{21} = 4 \cdot 7 + 5 \cdot 9 + 6 \cdot 11 = 28 + 45 + 66 = 139

Compute C22C_{22} (row 2 of AA · column 2 of BB):

C22=48+510+612=32+50+72=154C_{22} = 4 \cdot 8 + 5 \cdot 10 + 6 \cdot 12 = 32 + 50 + 72 = 154

Final result:

C=AB=[5864 139154]2×2C = AB = \begin{bmatrix} 58 & 64 \ 139 & 154 \end{bmatrix}_{2 \times 2}

[!example] Example 2 — Demonstrating Non-Commutativity

A=[12 34],B=[0110]A = \begin{bmatrix} 1 & 2 \ 3 & 4 \end{bmatrix}, \quad B = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}

Compute ABAB:

AB=[10+2111+2030+4131+40]=[2143]AB = \begin{bmatrix} 1 \cdot 0 + 2 \cdot 1 & 1 \cdot 1 + 2 \cdot 0 \\ 3 \cdot 0 + 4 \cdot 1 & 3 \cdot 1 + 4 \cdot 0 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 4 & 3 \end{bmatrix}

Compute BABA:

BA=[01+1302+1411+0312+04]=[3412]BA = \begin{bmatrix} 0 \cdot 1 + 1 \cdot 3 & 0 \cdot 2 + 1 \cdot 4 \\ 1 \cdot 1 + 0 \cdot 3 & 1 \cdot 2 + 0 \cdot 4 \end{bmatrix} = \begin{bmatrix} 3 & 4 \\ 1 & 2 \end{bmatrix}

Result: ABBAAB \neq BA

WHY? Because composition of transformations depends on order. Rotating then scaling is different from scaling then rotating.


[!example] Example 3 — Undefined Multiplication

A=[1234]2×2,B=[5 67]3×1A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}_{2 \times 2}, \quad B = \begin{bmatrix} 5 \ 6 \\ 7 \end{bmatrix}_{3 \times 1}

Check: AA is 2×22 \times \color{red}2, BB is 3×1\color{red}3 \times 1 → inner dimensions DON'T match (2 ≠ 3) ✗

Result: ABAB is undefined. You cannot multiply these matrices.

Why? There's a dimensional mismatchAA's rows expect 2 components, but BB provides 3.


[!mistake] Common Mistakes

Mistake 1: Thinking AB=BAAB = BA

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 ABAB and BABA are defined (square matrices of same size), they're usually different.

Verification: Always compute both and compare. Special cases exist (like A=IA = I 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: Am×n×Bn×pA_{m \times \color{red}n} \times B_{\color{red}n \times p}. 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 Aij×BijA_{ij} \times B_{ij} (called Hadamard product, notation ABA \circ B).

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 BB) that tells you how to make smoothies. Each recipe says "use 2 banas, 1 apple, 3 strawberries."

Now you have a price list (matrix AA) that tells you the cost per fruit in different stores.

When you multiply A×BA \times B, 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 AA)
  • Take smoothie #1's recipe (column 1 of BB)
  • 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"
ABBAAB \neq BA because you're composing transformations in opposite order.


Properties of Matrix Multiplication

  1. Associative: (AB)C=A(BC)(AB)C = A(BC)
  2. Distributive: A(B+C)=AB+ACA(B + C) = AB + AC
  3. NOT Commutative: ABBAAB \neq BA in general ✗
  4. Identity: AI=IA=AAI = IA = A where II is the identity matrix ✓
  5. Zero property: AO=OA \cdot O = O where OO is the zero matrix ✓

WHY associative? Because function composition is associative: (fg)h=f(gh)(f \circ g) \circ h = f \circ (g \circ h).


Connections

  • Matrix addition and scalar multiplication — simpler operations with same dimensions
  • Identity matrix — the multiplicative "1" for matrices
  • Inverse of a matrix — solving AB=IAB = I to find B=A1B = A^{-1}
  • Determinantsdet(AB)=det(A)det(B)\det(AB) = \det(A) \cdot \det(B) (comutativity holds for determinants!)
  • Linear transformations — matrices as function representations
  • Matrix transpose properties(AB)T=BTAT(AB)^T = B^T A^T (order reverses!)
  • System of linear equationsAx=bA\vec{x} = \vec{b} uses matrix-vector multiplication

Flashcards

What is the dimension requirement for multiplying Am×nA_{m \times n} and Bp×qB_{p \times q}? :: The number of columns in AA must equal the number of rows in BB, i.e., n=pn = p. Result is m×qm \times q.

What is the formula for entry (i,j)(i,j) in C=ABC = AB?
Cij=k=1nAikBkjC_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}, the dot product of row ii of AA with column jj of BB.
Is matrix multiplication commutative?
No. In general, ABBAAB \neq BA. Order matters because matrices represent composed transformations.
If AA is 3×43 \times 4 and BB is 4×24 \times 2, what are the dimensions of ABAB?
3×23 \times 2 (outer dimensions from m×n×pm \times n \times p).
Can you compute BABA if ABAB is defined?
Not necessarily. ABAB defined means columns of AA = rows of BB. For BABA, you'd need columns of BB = rows of AA, which is a different condition.
Why is matrix multiplication defined as row-column dot products?
To preserve composition of linear transformations: if C=ABC = AB, then Cx=A(Bx)C\vec{x} = A(B\vec{x}) for any vector x\vec{x}.
Give an example where ABAB is defined but BABA is not.
AA is 2×32 \times 3, BB is 3×43 \times 4. Then ABAB is 2×42 \times 4 (defined), but BABA requires 4=24 = 2 which is false (undefined).
What's the difference between matrix multiplication and Hadamard product?
Matrix multiplication uses row-column dot products with dimension requirement nA=mBn_A = m_B. Hadamard (element-wise) product requires same dimensions and multiplies corresponding entries: (AB)ij=AijBij(A \circ B)_{ij} = A_{ij} B_{ij}.
If AA and BB are both n×nn \times n, is AB=BAAB = BA guaranteed?
No. Even square matrices of same size usually don't commute. Special cases like identity or certain diagonal matrices do commute.
What is (AB)T(AB)^T equal to?
BTATB^T A^T (order reverses with transpose).

Concept Map

composed by

preserves

requires

gives

each entry is

expressed as

apply B then A

leads to

Linear transformations

Matrix multiplication AB

Function composition

Columns of A = rows of B

Result is m x p

Dot product row x column

Cij = sum Aik Bkj

Non-commutativity AB not BA

Order matters

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 ABAB multiply karte ho, matlab pehle BB wali transformation apply hoti hai, phir uske upar AA wali. Isiliye har entry ek row aur column ka dot product hota hai — row of AA ko column of BB ke saath multiply karke sum kar dete ho. Ye definition isliye aisi hai kyunki ye function composition ko preserve karti hai, yaani Cx=A(Bx)C\vec{x} = A(B\vec{x}) ekdum sahi baith jaye.

Ab ek important condition yaad rakhna: multiplication tabhi possible hai jab AA ke columns ki sankhya BB ke rows ke barabar ho. Yaani Am×nA_{m \times n} aur Bn×pB_{n \times p} — beech wale dono nn match karne chahiye, aur result m×pm \times p 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 ABBAAB \neq BA 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 3×5=5×33 \times 5 = 5 \times 3 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.

Go deeper — visual, from zero

Test yourself — Matrices & Determinants — Introduction

Connections