$\text{proj}_{\mathbf{u}}\mathbf{v}$proj u v — projection of v onto u
The component of v that lies in the direction of u. Computed as ⟨u,u⟩⟨v,u⟩u. The projection is a vector, not a scalar — it lives in Rn in the same direction as u. Subtracting it from v removes the u-direction entirely, leaving a vector orthogonal to u.
$Q, R$Q R — QR factors
The QR decomposition factors any matrix A with linearly independent columns as A=QR, where Q has orthonormal columns and R is upper triangular. The columns of Q are produced by Gram-Schmidt applied to the columns of A; the entries of R record the projection coefficients at each step.
$\mathbf{e}_k^*$e star k — orthonormalised vector
The k-th orthonormal basis vector produced by Gram-Schmidt. First compute the orthogonalised vector uk (by subtracting all projections), then normalise: ek∗=uk/∥uk∥. Not to be confused with the standard basis vectors ek.
01 · The Problem Gram-Schmidt Solves
Given any linearly independent set {v1,…,vk}, the goal is to produce an orthonormal set {q1,…,qk} that spans the same space. The two sets are related: for every m≤k, span{v1,…,vm}=span{q1,…,qm}.
The idea is geometric: take v2 and subtract the part of it that points in the v1 direction. What remains is orthogonal to v1. Normalise it. Repeat for each subsequent vector, subtracting every previously found direction.
Definition — Orthogonal Projection Onto a Vector
The projection of v onto u is:
projuv=⟨u,u⟩⟨v,u⟩u
The scalar ⟨u,u⟩⟨v,u⟩ is the projection coefficient — how much of u is contained in v. The vector v−projuv is orthogonal to u, because ⟨v−projuv,u⟩=⟨v,u⟩−∥u∥2⟨v,u⟩∥u∥2=0.
✓ Example — Projection Removes a Direction
v=(32), u=(20).
projuv=4+03(2)+2(0)(20)=46(20)=(30).
Remainder: v−projuv=(32)−(30)=(02).
Check: (02)⋅(20)=0 ✓ — the remainder is orthogonal to u, pointing purely in the y-direction.
02 · The Gram-Schmidt Algorithm
Definition — Gram-Schmidt Process
Given linearly independent {v1,…,vk}⊂Rn, compute orthonormal {q1,…,qk} by:
Step 1:u1=v1, q1=u1/∥u1∥.
Step j (for j=2,…,k):
uj=vj−∑i=1j−1⟨vj,qi⟩qi,qj=∥uj∥uj
Each uj is vj with all previously found directions removed. uj=0 because the original set was linearly independent — vj cannot be a linear combination of v1,…,vj−1.
Step-by-step — Gram-Schmidt on $\mathbf{v}_1=\begin{pmatrix}1\\1\\0\end{pmatrix}$, $\mathbf{v}_2=\begin{pmatrix}1\\0\\1\end{pmatrix}$, $\mathbf{v}_3=\begin{pmatrix}0\\1\\1\end{pmatrix}$
Verify orthonormality of result:{q1,q2,q3} are mutually orthogonal unit vectors spanning R3 ✓. The three original vectors and the three orthonormal vectors span the same space — any v∈R3 is a combination of either set.
❌ What Breaks — Linear Dependence Kills Gram-Schmidt
If v2=2v1, then u2=v2−⟨v2,q1⟩q1=2v1−2∥v1∥⋅∥v1∥v1=0. Dividing by ∥u2∥=0 is undefined. The algorithm collapses because v2 is entirely in the span of v1 — it adds no new direction to orthogonalise. Gram-Schmidt only works on linearly independent input.
03 · QR Decomposition
Gram-Schmidt produces a factorisation of the original matrix.
Definition — QR Decomposition
If A∈Rm×n has linearly independent columns, then:
A=QR
where Q∈Rm×n has orthonormal columns (QTQ=In) and R∈Rn×n is upper triangular with positive diagonal entries. The columns of Q are the Gram-Schmidt orthonormal vectors; the entries of R are the projection coefficients.
The connection: the j-th column of A is vj. Gram-Schmidt gives vj=r1jq1+r2jq2+⋯+rjjqj, so Rij=⟨vj,qi⟩ for i<j and Rjj=∥uj∥. Entries above the diagonal are projection coefficients; the diagonal is the norm of each orthogonalised vector; below the diagonal is zero.
Step-by-step — QR decomposition of $A=\begin{pmatrix}1&1\\1&0\\0&1\end{pmatrix}$
1
Run Gram-Schmidt on columns:v1=110, v2=101.
Read off R:r11=∥v1∥=2; r12=⟨v2,q1⟩=21; r22=∥u2∥=26.
Q=21210616−162,R=(202126)
4
Verify A=QR:QR should recover the original columns. Column 1: 2q1=110 ✓. Column 2: 21q1+26q2=21110+211−12=101 ✓.
04 · Quant Application — Orthogonal Factors in Return Models
In factor models for asset returns, you want a set of explanatory factors that are uncorrelated. If the raw factor candidates F1,F2,…,Fk are correlated, Gram-Schmidt produces an orthogonalised factor set G1,G2,…,Gk spanning the same space but with Cov(Gi,Gj)=0 for i=j.
This matters for attribution: with correlated factors, the individual contributions of each factor to a regression overlap. Orthogonalised factors each contribute uniquely — their variance contributions are additive.
QR also appears in numerical linear algebra: least squares problems min∥Ax−b∥ are solved stably via A=QR, giving x=R−1QTb — no need to form ATA, which can be ill-conditioned (Chapter 12).
05 · Practice Exercises
EXERCISE 11.1
Apply the projection formula: projuv=u⋅uv⋅uu. Then subtract to get the component orthogonal to u.
Apply Gram-Schmidt to v1=100, v2=110, v3=111 and write the resulting QR decomposition of the 3×3 matrix with these columns.
EXERCISE 11.4
Show that the orthogonal set produced by Gram-Schmidt is linearly independent using the property from Chapter 10: every orthogonal set of nonzero vectors is independent. Also show that span{q1,…,qk}=span{v1,…,vk} by induction.
Independence of {q1,…,qk}: By construction, ⟨qi,qj⟩=0 for i=j and ∥qi∥=1=0. Suppose ∑iciqi=0. Take the inner product with qj: ∑ici⟨qi,qj⟩=cj⋅1+∑i=jci⋅0=cj=0. So all cj=0 — linearly independent.
Same span: Induction on k. Base: span{q1}=span{v1} since q1=v1/∥v1∥. Inductive step: qk=(vk−∑i<k⟨vk,qi⟩qi)/∥⋅∥ is a linear combination of vk and q1,…,qk−1, which by inductive hypothesis lie in span{v1,…,vk−1}. So qk∈span{v1,…,vk}. Conversely, vk=∥uk∥qk+∑i<k⟨vk,qi⟩qi∈span{q1,…,qk}.
Prove that the Gram-Schmidt output {q1,…,qk} (a) is linearly independent and (b) spans the same space as {v1,…,vk}. Use properties of inner products and induction.
EXERCISE 11.5
In QR, the diagonal entries rkk=∥uk∥. A diagonal entry of R is zero ⟺∥uk∥=0⟺vk is in the span of v1,…,vk−1⟺ the columns of A are linearly dependent.
If columns of A are linearly independent: vk∈/span{v1,…,vk−1} for all k, so uk=0 for all k, so rkk=∥uk∥>0 — all diagonal entries are positive.
If some rkk=0: then ∥uk∥=0, meaning vk=∑i=1k−1⟨vk,qi⟩qi — vk is a linear combination of v1,…,vk−1, so the columns are linearly dependent.
Therefore: A has linearly independent columns ⟺ all diagonal entries of R are nonzero ⟺R is invertible. This gives a clean test for column independence from the QR factorisation.
Prove that the diagonal entries rkk of R in the QR decomposition are all nonzero if and only if the columns of A are linearly independent. What does a zero diagonal entry in R reveal about the columns of A?
EXERCISE 11.6
Orthogonalise the factor columns using Gram-Schmidt. The first orthogonal factor is the market return; the second is the market-neutral component of the value factor. Then check that the resulting factors have zero correlation.
Orthogonalised value factor: g2=f2−0.564f1=0.02−0.0170.03−0.0060.01−0.0280.04−0.011≈0.0030.024−0.0180.029.
The original value factor f2 contains a market component (the projection). After removing it, g2 is the pure value signal — market-neutral. Its correlation with f1 is now exactly zero. Regression of returns on (f1,g2) gives non-overlapping factor betas, so value and market contributions to returns are separately attributed.
A fund uses two return factors: market returns f1=(0.03,0.01,0.05,0.02)T and value-factor returns f2=(0.02,0.03,0.01,0.04)T over four periods. Apply one step of Gram-Schmidt to produce an orthogonalised value factor g2 that is uncorrelated with the market. Interpret what the orthogonalisation removes.
06 · Chapter Summary
Concept
Formula / Rule
Projection onto u
projuv=⟨u,u⟩⟨v,u⟩u
Orthogonal remainder
v−projuv⊥u
Gram-Schmidt step j
uj=vj−∑i<j⟨vj,qi⟩qi; qj=uj/∥uj∥
Fails when
Input is linearly dependent; uj=0 for some j
QR decomposition
A=QR; Q has orthonormal cols; R upper triangular
R diagonal entries
rkk=∥uk∥>0⟺ columns of A are independent
Span preserved
span{q1,…,qk}=span{v1,…,vk}
Quant use
Orthogonal factor models; stable numerical least squares
Next: Chapter 12 — Projections & Least Squares derives the normal equations from the projection framework, showing that the ordinary least squares regression solution is the orthogonal projection of the data onto the column space of the design matrix.