🎯 What is Orthogonality?
Orthogonal is just a fancy word for perpendicular — a 90° angle.
This entire chapter is about:
- When are two vectors orthogonal?
- When are two subspaces orthogonal?
- When are bases orthogonal?
1️⃣ Orthogonal Vectors
- The Test: Two vectors x and y are orthogonal if: $\boxed{x^T y = 0}$
- This is the dot product = x₁y₁ + x₂y₂ + ... + xₙyₙ = 0
Where does this come from? (Pythagoras!)
- For a right triangle with sides x, y and hypotenuse x+y: $\|x\|^2 + \|y\|^2 = \|x+y\|^2$
- Expanding the right side:$(x + y)^T (x + y) = x^T x + x^T y + y^T x + y^T y$
- Since $x^T y = y^T x \quad \text{for real vectors:}$ $\|x + y\|^2 = \|x\|^2 + 2x^T y + \|y\|^2$
- $\text{For Pythagoras: } 2x^T y = 0 \Rightarrow x^T y = 0$
- Length squared of a vector: $\|x\|^2 = x^T x = x_1^2 + x_2^2 + \ldots + x_n^2$
Example:
x = [1, 2, 3]
y = [1, -2, 1]
x·y = (1)(1) + (2)(-2) + (3)(1) = 1 - 4 + 3 = 0 ✅ ORTHOGONAL!
Check Pythagoras: x+y = [2, 0, 4]
||x+y||² = 4 + 0 + 16 = 20
||x||² + ||y||² = 14 + 6 = 20 ✅
Special note:
The zero vector is orthogonal to EVERY vector (0·y = 0 always)
2️⃣ Orthogonal Subspaces
Definition: Subspace S is orthogonal to subspace T means: $\boxed{\text{Every vector in S is perpendicular to every vector in T}}$
Common Mistake — Wall and Floor:
- The blackboard (a plane) and the floor (another plane) look perpendicular — but they are NOT orthogonal subspaces!
- Why? Because the line where they meet (the bottom of the board) is in BOTH subspaces.
A vector can't be perpendicular to itself (unless it's zero).
Key Rule: If two subspaces share any non-zero vector, they CANNOT be orthogonal
When ARE two subspaces orthogonal?
Two subspaces $S_1$ and $S_2$ are orthogonal if every vector $u \in S_1$ is orthogonal (perpendicular) to every vector $v \in S_2$. This means their dot product (or inner product) is zero, $u \cdot v = 0$ (or $u^T v = 0$) for all pairs of vectors. They share only the zero vector in common, i.e., $S_1 \cap S_2 = \{0\}$.
In 2D (the plane), possible subspaces are:
- The zero vector
- A line through origin
- The whole plane
Two lines through origin are orthogonal when they meet at exactly 90°. They only share the zero vector — that's what makes it work!
3️⃣ The Big Result: Row Space ⊥ Null Space
Statement: $\text{Row space of } A \perp \text{Null space of } A$
Proof (simple!): Take any vector x in the null space → Ax = 0
Write this out row by row:
[row 1 of A] · x = 0
[row 2 of A] · x = 0
⋮
[row m of A] · x = 0
- Each row is perpendicular to x!
- Now take any combination of rows: c₁(row 1) + c₂(row 2) + ... — that's any vector in the row space.
Is it perpendicular to x?
Now take any linear combination of rows:
\[
c_1(\text{row}_1 . x) + c_2(\text{row}_2 . x) + \ldots = c1(0)+c2(0)+…=0✓
\]
Therefore: Every vector in row space ⊥ every vector in null space ✅
Similarly (same proof for Aᵀ): $\boxed{\text{Column space of } A \perp \text{Left null space of } A}$
4️⃣ Orthogonal Complements
The null space doesn't just contain SOME vectors perpendicular to the row space — it contains ALL of them.
This is called being orthogonal complements:
| Pair | Space | Dimensions |
|---|
| Row space & Null space | Rⁿ | r + (n−r) = n |
| Column space & Left null space | Rᵐ | r + (m−r) = m |
Together they perfectly fill the entire space — no gaps, no overlaps (except at zero)
Visual:
Rⁿ
┌─────────────────┐
│ Row Space │ dim = r
│ (dim r) │
├─────────────────┤ ← 90° between them
│ Null Space │ dim = n-r
│ (dim n-r) │
└─────────────────┘
r + (n-r) = n ✅
5️⃣ The Problem This Leads To
Real life gives us too many equations with noise:
Example — Satellite tracking:
- 1000 measurements (equations)
- Only 6 unknowns (position parameters)
- Each measurement has noise
So Ax = b has NO exact solution because b is contaminated with noise.
What do we do?
- Can't ignore equations (wasteful)
- Can't solve exactly (impossible)
- → Find the BEST POSSIBLE solution
The key equation that saves us: $\boxed{A^TA\hat{x} = A^Tb}$
Properties of AᵀA:
- Square: (n×m)(m×n) = n×n ✅
- Symmetric: (AᵀA)ᵀ = AᵀA ✅
- Invertible when: columns of A are independent ✅
- Rank of AᵀA = Rank of A (always!)
Some Important Points :
- AX=b → asks for exact solution
- $A^T A \hat{x} = A^T b$ → gives best possible approximation
- We use it when: 👉 AX=b has NO solution
- This happens when:b is not in the column space of A
- We find $\hat{x}$ such that: $A\hat{x} \approx b$ i.e., as close as possible
- This becomes a "best fit" problem
- We minimize error: $\|A\hat{x} - b\|^2$
This is called: 👉 Least Squares Problem
WHY does this work?
- Let’s define error: $e = b - A\hat{x}$
- Key idea: We force error to be perpendicular to column space of A
- That means: $A^T e = 0$
- Substitute e: $A^T (b - A\hat{x}) = 0$, $A^T b = A^T A \hat{x}$
✅ That’s how the equation comes!
PROJECTIONS
🎯 Why Do We Project?
The core problem:
Ax = b often has NO solution because b is not in the column space of A
The solution:
Change b to the closest vector that IS in the column space → call it p Then solve Ax̂ = p instead
The closest point in the column space = the projection of b
6️⃣ Projection onto a Line (1D)
Setup:
- Line through vector a (a 1D subspace)
- Vector b (probably not on the line)
- Find p = closest point on the line to b
The Key Geometric Fact: The error vector e = b − p must be perpendicular to a
b
/|
/ | e = b - p
/ | (error, perpendicular to line)
/ |
/ ↓
o-----p--------→ a
p is on the line, e ⊥ a
Finding the Formula: Since p is on the line: p = xa (for some scalar x)
The perpendicularity condition: aᵀ(b − xa) = 0
Expanding: $a^T b - x\, a^T a = 0 \Rightarrow x\, a^T a = a^T b $
$\boxed{x = \frac{a^T b}{a^T a}}$
Therefore the projection: $\boxed{p = xa = \frac{a^Tb}{a^Ta} \cdot a}$
The Projection Matrix:
- We want a matrix P such that p = Pb
- From the formula: $p = a \cdot \frac{a^Tb}{a^Ta} = \frac{aa^T}{a^Ta} \cdot b$
- Therefore: $\boxed{P = \frac{aa^T}{a^Ta}}$
Understanding the formula:
aa^T ← (n×1)(1×n) = n×n MATRIX
P = ──────
a^Ta ← (1×n)(n×1) = scalar NUMBER
Numerator = column × row = a full matrix Denominator = row × column = just a number Result = a matrix!
7️⃣ Properties of Projection Matrix P
Property 1 — Symmetric: $P^T = P$
Why? $(aa^T)^T = (a^T)^T a^T = aa^T$ ✅ The denominator is a scalar (unchanged by transpose) ✅
Property 2 — P² = P (project twice = same as once): If you project a vector onto a line, then project again — you stay in the same place!
$P^2 = \frac{aa^T}{a^T a}\cdot\frac{aa^T}{a^T a} = \frac{a(a^Ta)a^T}{(a^Ta)^2} = \frac{aa^T}{a^Ta} = P$
Property 3 — Rank 1: Column space of P = line through a (just 1 direction) → rank = 1
Quick checks:
| What changes | Effect on p |
|---|
| Double b → 2b | p doubles too (2p) |
| Double a → 2a | p stays the same! (still same line) |
| Replace a with −a | p stays the same! (still same line) |
8️⃣ Projection onto a Subspace (Higher Dimensions)
Setup:
- Subspace spanned by columns a₁, a₂, ..., aₙ
- Put them as columns of matrix A
- Vector b (probably not in column space)
- Find p = projection of b onto column space of A
The Key Geometric Fact: Error e = b − p must be perpendicular to the entire subspace. This means e ⊥ a₁ AND e ⊥ a₂ AND ... e ⊥ aₙ
Written as equations:
a₁ᵀ(b − Ax̂) = 0
a₂ᵀ(b − Ax̂) = 0
⋮
aₙᵀ(b − Ax̂) = 0
Combined as one matrix equation:
$A^T(b - A\hat{x}) = 0 \Rightarrow A^T A \hat{x} = A^T b$
This is the Normal Equation — the most important equation in this chapter!
9️⃣ The Three Key Formulas
Formula 1 — Best solution x̂: $\boxed{\hat{x} = (A^T A)^{-1} A^T b}$
Formula 2 — Projection vector p: $\boxed{p = A\hat{x} = A(A^T A)^{-1} A^T b}$
Formula 3 — Projection Matrix P: $\boxed{P = A(A^T A)^{-1} A^T}$
Properties of this P:
- Symmetric: Pᵀ = P ✅
- P² = P: Project twice = same result ✅
- Column space of P = column space of A ✅
⚠️ Note: You CANNOT simplify A(AᵀA)⁻¹Aᵀ = I unless A is square! If A is not square, it has no inverse — leave the formula as is!
Special case — if A is square invertible: Column space = all of Rⁿ → projection = identity P = A(AᵀA)⁻¹Aᵀ = AA⁻¹(Aᵀ)⁻¹Aᵀ = I ✅
🎯 The Projection Formula: $\boxed{P = A(A^TA)^{-1}A^T}$
This matrix takes any vector b and projects it to the nearest point in the column space of A.
🔢 Two Extreme Cases
Case 1 — b is ALREADY in the column space: If b is in the column space → b = Ax for some x
$Pb = A(A^TA)^{-1}A^T \cdot Ax = A(A^TA)^{-1}(A^TA)x = Ax = b$
Result: Pb = b — projection leaves it unchanged ✅
Case 2 — b is PERPENDICULAR to the column space: If b ⊥ column space → b is in the null space of Aᵀ → Aᵀb = 0
$Pb = A(A^TA)^{-1}\underbrace{A^Tb}_{=0} = 0$
Result: Pb = 0 — projection kills it completely ✅
General Case (any b): Every vector b splits into two perpendicular parts: $\boxed{b = p + e}$
| Part | Lives in | Formula |
|---|
| p = projection | Column space of A | p = Pb |
| e = error | Left null space of A (⊥ to col space) | e = (I−P)b |
🔑 I − P is Also a Projection!
If P projects onto the column space, then (I − P) projects onto the perpendicular complement:
| Property | P | I − P |
|---|
| Symmetric | ✅ Pᵀ = P | ✅ (I−P)ᵀ = I−P |
| Idempotent | ✅ P² = P | ✅ (I−P)² = I−P |
Algebra confirms what geometry already tells you!
LEAST SQUARES: FITTING A LINE
🎯 The Problem
Given 3 data points:
Find the best line: b = C + Dt
No line passes through all 3 points → find the best possible line.
🔢 Setting Up the Equations
For a perfect fit, we'd need:
C + D(1) = 1 → C + D = 1
C + D(2) = 2 → C + 2D = 2
C + D(3) = 2 → C + 3D = 2
Matrix form Ax = b:
$\underbrace{\begin{pmatrix}1 & 1 \\ 1 & 2 \\ 1 & 3\end{pmatrix}}_{A}
\underbrace{\begin{pmatrix}C \\ D\end{pmatrix}}_{x}
=
\underbrace{\begin{pmatrix}1 \\ 2 \\ 2\end{pmatrix}}_{b}$
3 equations, 2 unknowns → NO exact solution
🔢 What Does "Best" Mean?
Each equation gives an error:
e1 = (C + D) − 1
e2 = (C + 2D) − 2
e3 = (C + 3D) − 2
Minimize the total squared error:
Minimize $ \|e\|^2 = e_1^2 + e_2^2 + e_3^2$. This is called Least Squares (also called Linear Regression in statistics)
⚠️ Note on outliers: Squaring amplifies large errors. One bad measurement (outlier) can distort the whole solution. Real statisticians handle this carefully!
🔢 Solving Using Normal Equations
The key equation: $A^T A \hat{x} = A^T b$
Step 1 — Compute $A^T A$: $A^T A =
\begin{pmatrix}
1 & 1 & 1 \\
1 & 2 & 3
\end{pmatrix}
\begin{pmatrix}
1 & 1 \\
1 & 2 \\
1 & 3
\end{pmatrix}
=
\begin{pmatrix}
3 & 6 \\
6 & 14
\end{pmatrix}$
Step 2 — Compute $A^T b$: $A^T b =
\begin{pmatrix}
1 & 1 & 1 \\
1 & 2 & 3
\end{pmatrix}
\begin{pmatrix}
1 \\
2 \\
2
\end{pmatrix}
=
\begin{pmatrix}
5 \\
11
\end{pmatrix}$
Step 3 — Solve the normal equations: $\begin{pmatrix}
3 & 6 \\
6 & 14
\end{pmatrix}
\begin{pmatrix}
C \\
D
\end{pmatrix}
=
\begin{pmatrix}
5 \\
11
\end{pmatrix}$
Using elimination: $6C + 12D = 10$ , $6C + 14D = 11$
Subtracting: $2D = 1 \Rightarrow D = \frac{1}{2}$
Substitute back: $3C + 6\left(\frac{1}{2}\right) = 5 \Rightarrow 3C + 3 = 5 \Rightarrow C = \frac{2}{3}$
Best fit line: $b = \frac{2}{3} + \frac{1}{2} t$
🔢 Computing the Projection and Error
Values on the best line (projection p):
P1 = 2/3 + 1/2(1) = 7/6
P2 = 2/3 + 1/2(2) = 5/3
P3 = 2/3 + 1/2(3) = 13/6
$p = \begin{pmatrix}7/6\\5/3\\13/6\end{pmatrix}$ Error vector e = b − p: $e = \begin{pmatrix}1\\2\\2\end{pmatrix} - \begin{pmatrix}7/6\\5/3\\13/6\end{pmatrix} = \begin{pmatrix}-1/6\\2/6\\-1/6\end{pmatrix}$
✅ Verification — e ⊥ p: $p \cdot e = \frac{7}{6}\left(-\frac{1}{6}\right) + \frac{5}{3}\left(\frac{2}{6}\right) + \frac{13}{6}\left(-\frac{1}{6}\right)$
✅ Verification — e ⊥ entire column space: e must be perpendicular to every vector in the column space, not just p!
e · [1,1,1] = -1/6 + 2/6 - 1/6 = 0 ✅
e · [1,2,3] = -1/6 + 4/6 - 3/6 = 0 ✅
This confirms e is in the Left Null Space of A — perpendicular to the entire column space ✅
📐 Two Pictures of the Same Problem
| Picture 1 (geometric) | Picture 2 (vector) |
|---|
| 3 points on a graph | Vector b in R³ |
| Best fit line | Projection p in column space |
| Vertical distances e1, e2, e3 | Error vector e |
| Line parameters C, D | Combination coefficients |
Same math — two different ways to see it!

WHY AᵀA IS INVERTIBLE?
🎯 Key Theorem: $\boxed{A^T A \text{ is invertible} \iff \text{columns of } A \text{ are independent}}$
Goal: Show that if AᵀAx = 0, then x = 0
Step 1: Multiply both sides on left by xᵀ: $x^T A^T A x = 0$
Step 2: Rewrite using parentheses: $Ax)^T(Ax) = 0$
Step 3: This equals ‖Ax‖² = 0, so: Ax=0
Step 4: But columns of A are independent → null space of A = {0}: x=0✓
Therefore AᵀA has no non-zero null space → AᵀA is invertible ✅
ORTHONORMAL VECTORS & MATRICES
🎯 What Does Orthonormal Mean?
Vectors q₁, q₂, ..., qₙ are orthonormal when they are:
| Property | Math | Meaning |
|---|
| Orthogonal | qᵢᵀqⱼ = 0 (i ≠ j) | Every pair is perpendicular |
| Normal | qᵢᵀqᵢ = 1 | Every vector has length 1 |
Combined into one neat condition: $ q_i^T q_j = \begin{cases} 1 & \text{if } i = j \\ 0 & \text{if } i \ne j \end{cases} $
Use the letter Q whenever columns are orthonormal — it's a visual reminder!
🔢 The Magic: QᵀQ = I
Put orthonormal vectors as columns of matrix Q. Then compute QᵀQ:
Qᵀ has these vectors as ROWS
Q has these vectors as COLUMNS
(QᵀQ)ᵢⱼ = (row i of Qᵀ) · (col j of Q)
= qᵢᵀ · qⱼ
= 0 (if i≠j) or 1 (if i=j)
$\boxed{Q^TQ = I}$
Rows times columns = all those dot products = identity!
🔑 Square vs Rectangular Q
| Case | Property | Result |
|---|
| Q is square | Qᵀ = Q⁻¹ | Called an orthogonal matrix |
| Q is rectangular | Only QᵀQ = I (not QQᵀ) | Called matrix with orthonormal columns |
By convention: only square Q with orthonormal columns is called an orthogonal matrix
📝 Examples of Orthogonal Matrices
Example 1 — Permutation matrix: $Q = \begin{pmatrix}0&0&1\\1&0&0\\0&1&0\end{pmatrix}$
Each column = a standard basis vector → unit vectors, perpendicular → orthogonal! ✅
Example 2 — Rotation matrix: $Q = \begin{pmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{pmatrix}$
Both columns have length 1, dot product = 0 → orthogonal! ✅
WHY ORTHONORMAL COLUMNS MAKE LIFE EASY?
🎯 Projection Matrix Simplifies!
General projection matrix onto column space of A:
$P = A(A^T A)^{-1}A^T \;\leftarrow\; \text{messy, requires inversion}$
When A = Q (orthonormal columns):
$P = Q(Q^TQ)^{-1}Q^T = Q \cdot I \cdot Q^T = QQ^T$
$\boxed{P = QQ^T}\ \leftarrow\ \text{no inversion is needed}$
Verify the two projection properties:
- Symmetric? $(QQ^T)^T = (Q^T)^T Q^T = QQ^T \;\checkmark$
- P² = P? $(QQ^T)(QQ^T) = Q(\underbrace{Q^T Q}_{= I})Q^T = QQ^T \;\checkmark$
Special case — Q is square:
- Column space = all of Rⁿ → projection = identity
- $P = QQ^T = I \quad \text{(when $Q$ is square)}$
🎯 Normal Equations Simplify!
General normal equation: $A^T A \hat{x} = A^T b \quad \leftarrow \text{must solve a system}$
When A = Q: $Q^T Q \hat{x} = Q^T b \;\Rightarrow\; I\hat{x} = Q^T b \;\Rightarrow\; \boxed{\hat{x} = Q^T b}$
No matrix to invert — just compute dot products!
Each component of x̂: $\hat{x}_i = q_i^T b$
The i-th component = projection of b onto the i-th basis vector This is one of the most important formulas in mathematics!
GRAM-SCHMIDT PROCESS
🎯 The Problem
Given: Independent vectors a, b (and possibly c, d, ...)
Goal: Produce orthonormal vectors q₁, q₂, ...
Why: Orthonormal bases make all calculations simple
🔢 Step-by-Step: Two Vectors
Step 1 — First vector (easy): Just take a as is. The direction is fine! $\boxed{A = a}$
Step 2 — Second vector (the key idea): b has a component along A and a component perpendicular to A.
We want the perpendicular part → subtract off the A-component!
b = (component along A) + (component ⊥ to A)
↓ ↓
(projection) (what we want!)
$\boxed{B = b - \frac{A^T b}{A^T A}\, A}$
This is exactly the error vector from the projection chapter!
Verify B ⊥ A: $$A^T B = A^T\!\left(b - \frac{A^T b}{A^T A}\,A\right)
= A^T b - \frac{A^T b}{A^T A}(A^T A)
= A^T b - A^T b
= 0 \;\checkmark$$
Step 3 — Normalize to get unit vectors: $\boxed{q_1 = \frac{A}{\|A\|}, \quad q_2 = \frac{B}{\|B\|}}$
⚠️ Square roots almost always appear here — unavoidable!
Three Vectors: Adding a Third
Given: A, B already orthogonal. Need C ⊥ A and C ⊥ B.
$\boxed{C = c - \frac{A^T c}{A^T A}\,A - \frac{B^T c}{B^T B}\,B}$
Logic: Start with c. Remove its A-component AND its B-component. What's left is perpendicular to both!
Then normalize:$\boxed{q_3 = \frac{C}{\|C\|}}$
📝 Numerical Example
Given:
a = [1, 1, 1]
b = [1, 0, 2]
Step 1 — A: $\begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix}$
Step 2 — B: Compute:
- $A^T b = (1)(1) + (1)(0) + (1)(2) = 3$
- $A^T A = (1)(1) + (1)(1) + (1)(1) = 3$
\[
B = b - \frac{3}{3} A
= \begin{pmatrix}1 \\ 0 \\ 2\end{pmatrix}
- \begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix}
= \begin{pmatrix}0 \\ -1 \\ 1\end{pmatrix}
\]
Check: \[
A^T B = (1)(0) + (1)(-1) + (1)(1) = 0 \;\checkmark
\]
Step 3 — Normalize:
\[
q_1 = \frac{A}{\|A\|} = \frac{1}{\sqrt{3}}
\begin{pmatrix}1 \\ 1 \\ 1\end{pmatrix},
\quad
q_2 = \frac{B}{\|B\|} = \frac{1}{\sqrt{2}}
\begin{pmatrix}0 \\ -1 \\ 1\end{pmatrix}
\]
Result: \[
Q =
\begin{pmatrix}
\frac{1}{\sqrt{3}} & 0 \\
\frac{1}{\sqrt{3}} & -\frac{1}{\sqrt{2}} \\
\frac{1}{\sqrt{3}} & \frac{1}{\sqrt{2}}
\end{pmatrix}
\]
Key observation:
- Column space of Q = same as column space of A
- Gram-Schmidt doesn't change the space — just rotates the basis to be orthonormal!
A = QR FACTORIZATION
🎯 Matrix Form of Gram-Schmidt
Just like elimination gave A = LU, Gram-Schmidt gives: $\boxed{A = QR}$
| Matrix | What it is |
|---|
| Q | Orthonormal columns (from Gram-Schmidt) |
| R | Upper triangular matrix |
Why is R upper triangular?
The entries of R are inner products: $R =
\begin{pmatrix}
a_1^T q_1 & 0 \\
a_2^T q_1 & a_2^T q_2
\end{pmatrix}$
The entry $a_1^Tq_2 = 0$ because Gram-Schmidt constructs q₂ to be perpendicular to a₁! → Each later q is perpendicular to all earlier a's → zeros below diagonal → upper triangular!
General pattern of R:
R = | a₁ᵀq₁ a₂ᵀq₁ a₃ᵀq₁ ... |
| 0 a₂ᵀq₂ a₃ᵀq₂ ... |
| 0 0 a₃ᵀq₃ ... |
| ⋮ ⋮ ⋮ |
📊 Big Picture: Matrix Factorizations
| Process | Factorization | What it does |
|---|
| Elimination | A = LU | Makes matrix triangular |
| Gram-Schmidt | A = QR | Makes matrix orthonormal |