LA 101
M05 · L02
Module 5: Orthogonality

The Gram-Schmidt Process

Given any linearly independent vectors, Gram-Schmidt builds an orthonormal basis — one direction at a time, subtracting what you already have.

01 / 11
LA 101
M05 · L02
The Problem

From Oblique to Orthogonal

Real-world vectors are rarely perpendicular. Gram-Schmidt converts any basis into an orthonormal basis — same subspace, clean geometry.

v₁…vₙ
any basis
→
 
q₁…qₙ
orthonormal
02 / 11
LA 101
M05 · L02
The Algorithm

Three Steps, Repeated

  • Take the next input vector vₖ
  • Subtract its projections onto q₁, …, qₖ₋₁
  • Normalize the residual to unit length
  • Repeat for each new vector
03 / 11
LA 101
M05 · L02
The Formula

Subtract Every Projection

Gram-Schmidt
\mathbf{u}_k = \mathbf{v}_k - \sum_{j=1}^{k-1}(\mathbf{q}_j^T\mathbf{v}_k)\mathbf{q}_j

Each inner product qⱼᵀvₖ measures how much of vₖ lies along qⱼ. Subtracting them all leaves a vector orthogonal to everything before it.

04 / 11
LA 101
M05 · L02
Step 1 & 2

The First Two Vectors

Step 1: normalize v₁
q₁ = v₁ / ‖v₁‖
Step 2: remove q₁ component from v₂
u₂ = v₂ − (q₁ᵀv₂)q₁, then q₂ = u₂/‖u₂‖
05 / 11
LA 101
M05 · L02
Hidden Factorization

A = QR

Gram-Schmidt on the columns of A produces the QR decomposition — Q has orthonormal columns, R is upper triangular.

QR Decomposition
A = QR,\quad Q^TQ = I
06 / 11
LA 101
M05 · L02
Why Upper Triangular?

Sequential Structure

Each vₖ only involves q₁ through qₖ (earlier vectors can't see later ones). That "one-way" dependency makes R upper triangular.

Entry R[i,j]
= qᵢᵀvⱼ (the projection scalar from Gram-Schmidt)
07 / 11
LA 101
M05 · L02
Numerical Stability

Modified Gram-Schmidt

  • Classical GS accumulates rounding errors
  • Modified GS updates the running vector after each subtraction
  • Same math, far better floating-point behavior
  • MGS is the standard in practice (LAPACK, NumPy)
08 / 11
LA 101
Knowledge Check

Check what stuck

Four questions from this lesson. Answer to see why — the explanation appears whether you were right or wrong. Nothing is scored or saved.

Question 1 of 0
Score 0/0

09 / 11
LA 101
M05 · L02
The Payoff

P = QQᵀ

Once you have an orthonormal basis Q, projection needs no matrix inversion. Just dot products.

  • Least squares — solve via back-substitution on R
  • Eigenvalues — QR iteration algorithm
  • Fourier series — projections onto sinusoidal basis
  • Signal processing — fast, stable inner products
10 / 11
LA 101
Up Next
Lesson 2 Complete

M5-L3: Orthogonal Matrices

You've built orthonormal bases with Gram-Schmidt. Next: matrices whose columns are orthonormal — a special family with remarkable properties for rotations and reflections.

11 / 11