Chapter 11

Gram-Schmidt Process

00 · Symbol Glossary

$\text{proj}_{\mathbf{u}}\mathbf{v}$proj u v — projection of v onto u

The component of v\mathbf{v} that lies in the direction of u\mathbf{u}. Computed as v,uu,uu\frac{\langle\mathbf{v},\mathbf{u}\rangle}{\langle\mathbf{u},\mathbf{u}\rangle}\mathbf{u}. The projection is a vector, not a scalar — it lives in Rn\mathbb{R}^n in the same direction as u\mathbf{u}. Subtracting it from v\mathbf{v} removes the u\mathbf{u}-direction entirely, leaving a vector orthogonal to u\mathbf{u}.

$Q, R$Q R — QR factors

The QR decomposition factors any matrix AA with linearly independent columns as A=QRA = QR, where QQ has orthonormal columns and RR is upper triangular. The columns of QQ are produced by Gram-Schmidt applied to the columns of AA; the entries of RR record the projection coefficients at each step.

$\mathbf{e}_k^*$e star k — orthonormalised vector

The kk-th orthonormal basis vector produced by Gram-Schmidt. First compute the orthogonalised vector uk\mathbf{u}_k (by subtracting all projections), then normalise: ek=uk/uk\mathbf{e}_k^* = \mathbf{u}_k / \|\mathbf{u}_k\|. Not to be confused with the standard basis vectors ek\mathbf{e}_k.


01 · The Problem Gram-Schmidt Solves

Given any linearly independent set {v1,,vk}\{\mathbf{v}_1, \ldots, \mathbf{v}_k\}, the goal is to produce an orthonormal set {q1,,qk}\{\mathbf{q}_1, \ldots, \mathbf{q}_k\} that spans the same space. The two sets are related: for every mkm \leq k, span{v1,,vm}=span{q1,,qm}\text{span}\{\mathbf{v}_1, \ldots, \mathbf{v}_m\} = \text{span}\{\mathbf{q}_1, \ldots, \mathbf{q}_m\}.

The idea is geometric: take v2\mathbf{v}_2 and subtract the part of it that points in the v1\mathbf{v}_1 direction. What remains is orthogonal to v1\mathbf{v}_1. Normalise it. Repeat for each subsequent vector, subtracting every previously found direction.

Definition — Orthogonal Projection Onto a Vector

The projection of v\mathbf{v} onto u\mathbf{u} is:

projuv=v,uu,uu\text{proj}_{\mathbf{u}}\mathbf{v} = \frac{\langle \mathbf{v}, \mathbf{u} \rangle}{\langle \mathbf{u}, \mathbf{u} \rangle}\,\mathbf{u}

The scalar v,uu,u\frac{\langle\mathbf{v},\mathbf{u}\rangle}{\langle\mathbf{u},\mathbf{u}\rangle} is the projection coefficient — how much of u\mathbf{u} is contained in v\mathbf{v}. The vector vprojuv\mathbf{v} - \text{proj}_\mathbf{u}\mathbf{v} is orthogonal to u\mathbf{u}, because vprojuv,u=v,uv,uu2u2=0\langle \mathbf{v} - \text{proj}_\mathbf{u}\mathbf{v},\, \mathbf{u} \rangle = \langle\mathbf{v},\mathbf{u}\rangle - \frac{\langle\mathbf{v},\mathbf{u}\rangle}{\|\mathbf{u}\|^2}\|\mathbf{u}\|^2 = 0.

✓ Example — Projection Removes a Direction

v=(32)\mathbf{v} = \begin{pmatrix}3\\2\end{pmatrix}, u=(20)\mathbf{u} = \begin{pmatrix}2\\0\end{pmatrix}.

projuv=3(2)+2(0)4+0(20)=64(20)=(30)\text{proj}_\mathbf{u}\mathbf{v} = \frac{3(2)+2(0)}{4+0}\begin{pmatrix}2\\0\end{pmatrix} = \frac{6}{4}\begin{pmatrix}2\\0\end{pmatrix} = \begin{pmatrix}3\\0\end{pmatrix}.

Remainder: vprojuv=(32)(30)=(02)\mathbf{v} - \text{proj}_\mathbf{u}\mathbf{v} = \begin{pmatrix}3\\2\end{pmatrix}-\begin{pmatrix}3\\0\end{pmatrix} = \begin{pmatrix}0\\2\end{pmatrix}.

Check: (02)(20)=0\begin{pmatrix}0\\2\end{pmatrix}\cdot\begin{pmatrix}2\\0\end{pmatrix} = 0 ✓ — the remainder is orthogonal to u\mathbf{u}, pointing purely in the yy-direction.


02 · The Gram-Schmidt Algorithm

Definition — Gram-Schmidt Process

Given linearly independent {v1,,vk}Rn\{\mathbf{v}_1, \ldots, \mathbf{v}_k\} \subset \mathbb{R}^n, compute orthonormal {q1,,qk}\{\mathbf{q}_1, \ldots, \mathbf{q}_k\} by:

Step 1: u1=v1\mathbf{u}_1 = \mathbf{v}_1, q1=u1/u1\quad\mathbf{q}_1 = \mathbf{u}_1/\|\mathbf{u}_1\|.

Step jj (for j=2,,kj = 2, \ldots, k):

uj=vji=1j1vj,qiqi,qj=ujuj\mathbf{u}_j = \mathbf{v}_j - \sum_{i=1}^{j-1} \langle \mathbf{v}_j, \mathbf{q}_i \rangle\, \mathbf{q}_i, \qquad \mathbf{q}_j = \frac{\mathbf{u}_j}{\|\mathbf{u}_j\|}

Each uj\mathbf{u}_j is vj\mathbf{v}_j with all previously found directions removed. uj0\mathbf{u}_j \neq \mathbf{0} because the original set was linearly independent — vj\mathbf{v}_j cannot be a linear combination of v1,,vj1\mathbf{v}_1, \ldots, \mathbf{v}_{j-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}$
1

Normalise v1\mathbf{v}_1: v1=1+1+0=2\|\mathbf{v}_1\| = \sqrt{1+1+0} = \sqrt{2}.

q1=12(110)\mathbf{q}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix}
2

Project v2\mathbf{v}_2 onto q1\mathbf{q}_1: v2,q1=12(11+01+10)=12\langle\mathbf{v}_2,\mathbf{q}_1\rangle = \frac{1}{\sqrt{2}}(1\cdot1 + 0\cdot1 + 1\cdot0) = \frac{1}{\sqrt{2}}.

Projection: 12q1=1212(110)=12(110)\frac{1}{\sqrt{2}} \cdot \mathbf{q}_1 = \frac{1}{\sqrt{2}}\cdot\frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix} = \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix}.

3

Subtract projection from v2\mathbf{v}_2: remove the q1\mathbf{q}_1 component.

u2=(101)12(110)=(1/21/21)\mathbf{u}_2 = \begin{pmatrix}1\\0\\1\end{pmatrix} - \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix} = \begin{pmatrix}1/2\\-1/2\\1\end{pmatrix}

The 12\frac{1}{2} entries come from 112=121 - \frac{1}{2}=\frac{1}{2} and 012=120 - \frac{1}{2}=-\frac{1}{2}.

Check: u2q1=12(121+(12)1+10)=0\mathbf{u}_2\cdot\mathbf{q}_1 = \frac{1}{\sqrt{2}}(\frac{1}{2}\cdot1+(-\frac{1}{2})\cdot1+1\cdot0) = 0 ✓.

4

Normalise u2\mathbf{u}_2: u2=14+14+1=32=62\|\mathbf{u}_2\| = \sqrt{\frac{1}{4}+\frac{1}{4}+1} = \sqrt{\frac{3}{2}} = \frac{\sqrt{6}}{2}.

q2=26(1/21/21)=16(112)\mathbf{q}_2 = \frac{2}{\sqrt{6}}\begin{pmatrix}1/2\\-1/2\\1\end{pmatrix} = \frac{1}{\sqrt{6}}\begin{pmatrix}1\\-1\\2\end{pmatrix}

Multiplied numerator and denominator by 2: 2612=16\frac{2}{\sqrt{6}}\cdot\frac{1}{2}=\frac{1}{\sqrt{6}} and 261=26\frac{2}{\sqrt{6}}\cdot1=\frac{2}{\sqrt{6}}.

5

Project v3\mathbf{v}_3 onto q1\mathbf{q}_1 and q2\mathbf{q}_2:

v3,q1=12(0+1+0)=12\langle\mathbf{v}_3,\mathbf{q}_1\rangle = \frac{1}{\sqrt{2}}(0+1+0) = \frac{1}{\sqrt{2}}.

v3,q2=16(01+1(1)+12)=16\langle\mathbf{v}_3,\mathbf{q}_2\rangle = \frac{1}{\sqrt{6}}(0\cdot1+1\cdot(-1)+1\cdot2) = \frac{1}{\sqrt{6}}.

6

Subtract both projections from v3\mathbf{v}_3:

u3=(011)1212(110)1616(112)\mathbf{u}_3 = \begin{pmatrix}0\\1\\1\end{pmatrix} - \frac{1}{\sqrt{2}}\cdot\frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix} - \frac{1}{\sqrt{6}}\cdot\frac{1}{\sqrt{6}}\begin{pmatrix}1\\-1\\2\end{pmatrix}

=(011)12(110)16(112)=(01216112+161026)=(232323)= \begin{pmatrix}0\\1\\1\end{pmatrix} - \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix} - \frac{1}{6}\begin{pmatrix}1\\-1\\2\end{pmatrix} = \begin{pmatrix}0-\frac{1}{2}-\frac{1}{6}\\1-\frac{1}{2}+\frac{1}{6}\\1-0-\frac{2}{6}\end{pmatrix} = \begin{pmatrix}-\frac{2}{3}\\\frac{2}{3}\\\frac{2}{3}\end{pmatrix}

u3=49+49+49=43=23\|\mathbf{u}_3\| = \sqrt{\frac{4}{9}+\frac{4}{9}+\frac{4}{9}} = \sqrt{\frac{4}{3}} = \frac{2}{\sqrt{3}}.

q3=3223(111)=13(111)\mathbf{q}_3 = \frac{\sqrt{3}}{2}\cdot\frac{2}{3}\begin{pmatrix}-1\\1\\1\end{pmatrix} = \frac{1}{\sqrt{3}}\begin{pmatrix}-1\\1\\1\end{pmatrix}
7

Verify orthonormality of result: {q1,q2,q3}\{\mathbf{q}_1,\mathbf{q}_2,\mathbf{q}_3\} are mutually orthogonal unit vectors spanning R3\mathbb{R}^3 ✓. The three original vectors and the three orthonormal vectors span the same space — any vR3\mathbf{v}\in\mathbb{R}^3 is a combination of either set.

❌ What Breaks — Linear Dependence Kills Gram-Schmidt

If v2=2v1\mathbf{v}_2 = 2\mathbf{v}_1, then u2=v2v2,q1q1=2v12v1v1v1=0\mathbf{u}_2 = \mathbf{v}_2 - \langle\mathbf{v}_2,\mathbf{q}_1\rangle\mathbf{q}_1 = 2\mathbf{v}_1 - 2\|\mathbf{v}_1\|\cdot\frac{\mathbf{v}_1}{\|\mathbf{v}_1\|} = \mathbf{0}. Dividing by u2=0\|\mathbf{u}_2\|=0 is undefined. The algorithm collapses because v2\mathbf{v}_2 is entirely in the span of v1\mathbf{v}_1 — 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 ARm×nA \in \mathbb{R}^{m \times n} has linearly independent columns, then:

A=QRA = QR

where QRm×nQ \in \mathbb{R}^{m \times n} has orthonormal columns (QTQ=InQ^TQ = I_n) and RRn×nR \in \mathbb{R}^{n \times n} is upper triangular with positive diagonal entries. The columns of QQ are the Gram-Schmidt orthonormal vectors; the entries of RR are the projection coefficients.

The connection: the jj-th column of AA is vj\mathbf{v}_j. Gram-Schmidt gives vj=r1jq1+r2jq2++rjjqj\mathbf{v}_j = r_{1j}\mathbf{q}_1 + r_{2j}\mathbf{q}_2 + \cdots + r_{jj}\mathbf{q}_j, so Rij=vj,qiR_{ij} = \langle\mathbf{v}_j,\mathbf{q}_i\rangle for i<ji < j and Rjj=ujR_{jj} = \|\mathbf{u}_j\|. 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)\mathbf{v}_1=\begin{pmatrix}1\\1\\0\end{pmatrix}, v2=(101)\mathbf{v}_2=\begin{pmatrix}1\\0\\1\end{pmatrix}.

v1=2\|\mathbf{v}_1\|=\sqrt{2}, so q1=12(110)\mathbf{q}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix}.

2

Orthogonalise v2\mathbf{v}_2: v2,q1=12(1+0+0)=12\langle\mathbf{v}_2,\mathbf{q}_1\rangle = \frac{1}{\sqrt{2}}(1+0+0)=\frac{1}{\sqrt{2}}.

u2=(101)1212(110)=(112121)=(12121)\mathbf{u}_2 = \begin{pmatrix}1\\0\\1\end{pmatrix}-\frac{1}{\sqrt{2}}\cdot\frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\end{pmatrix} = \begin{pmatrix}1-\frac{1}{2}\\-\frac{1}{2}\\1\end{pmatrix} = \begin{pmatrix}\frac{1}{2}\\-\frac{1}{2}\\1\end{pmatrix}.

u2=14+14+1=64=62\|\mathbf{u}_2\|=\sqrt{\frac{1}{4}+\frac{1}{4}+1}=\sqrt{\frac{6}{4}}=\frac{\sqrt{6}}{2}, so q2=16(112)\mathbf{q}_2=\frac{1}{\sqrt{6}}\begin{pmatrix}1\\-1\\2\end{pmatrix}.

3

Read off RR: r11=v1=2r_{11}=\|\mathbf{v}_1\|=\sqrt{2}; r12=v2,q1=12r_{12}=\langle\mathbf{v}_2,\mathbf{q}_1\rangle=\frac{1}{\sqrt{2}}; r22=u2=62r_{22}=\|\mathbf{u}_2\|=\frac{\sqrt{6}}{2}.

Q=(12161216026),R=(212062)Q = \begin{pmatrix}\frac{1}{\sqrt{2}}&\frac{1}{\sqrt{6}}\\\frac{1}{\sqrt{2}}&\frac{-1}{\sqrt{6}}\\0&\frac{2}{\sqrt{6}}\end{pmatrix}, \quad R = \begin{pmatrix}\sqrt{2}&\frac{1}{\sqrt{2}}\\0&\frac{\sqrt{6}}{2}\end{pmatrix}
4

Verify A=QRA=QR: QRQR should recover the original columns. Column 1: 2q1=(110)\sqrt{2}\mathbf{q}_1 = \begin{pmatrix}1\\1\\0\end{pmatrix} ✓. Column 2: 12q1+62q2=12(110)+12(112)=(101)\frac{1}{\sqrt{2}}\mathbf{q}_1+\frac{\sqrt{6}}{2}\mathbf{q}_2 = \frac{1}{2}\begin{pmatrix}1\\1\\0\end{pmatrix}+\frac{1}{2}\begin{pmatrix}1\\-1\\2\end{pmatrix}=\begin{pmatrix}1\\0\\1\end{pmatrix} ✓.


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,,FkF_1, F_2, \ldots, F_k are correlated, Gram-Schmidt produces an orthogonalised factor set G1,G2,,GkG_1, G_2, \ldots, G_k spanning the same space but with Cov(Gi,Gj)=0\text{Cov}(G_i, G_j) = 0 for iji \neq 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 minAxb\min \|A\mathbf{x}-\mathbf{b}\| are solved stably via A=QRA=QR, giving x=R1QTb\mathbf{x} = R^{-1}Q^T\mathbf{b} — no need to form ATAA^TA, which can be ill-conditioned (Chapter 12).


05 · Practice Exercises

EXERCISE 11.1

Apply the projection formula: projuv=vuuuu\text{proj}_\mathbf{u}\mathbf{v} = \frac{\mathbf{v}\cdot\mathbf{u}}{\mathbf{u}\cdot\mathbf{u}}\mathbf{u}. Then subtract to get the component orthogonal to u\mathbf{u}.

u=(34)\mathbf{u}=\begin{pmatrix}3\\4\end{pmatrix}, v=(51)\mathbf{v}=\begin{pmatrix}5\\1\end{pmatrix}.

uu=9+16=25\mathbf{u}\cdot\mathbf{u} = 9+16=25. vu=15+4=19\mathbf{v}\cdot\mathbf{u} = 15+4=19.

projuv=1925(34)=(57/2576/25)\text{proj}_\mathbf{u}\mathbf{v} = \frac{19}{25}\begin{pmatrix}3\\4\end{pmatrix} = \begin{pmatrix}57/25\\76/25\end{pmatrix}.

Orthogonal component: vprojuv=(557/25176/25)=(68/2551/25)\mathbf{v}-\text{proj}_\mathbf{u}\mathbf{v} = \begin{pmatrix}5-57/25\\1-76/25\end{pmatrix} = \begin{pmatrix}68/25\\-51/25\end{pmatrix}.

Verify orthogonality: (68/2551/25)(34)=125(204204)=0\begin{pmatrix}68/25\\-51/25\end{pmatrix}\cdot\begin{pmatrix}3\\4\end{pmatrix} = \frac{1}{25}(204-204)=0 ✓.

Compute projuv\text{proj}_\mathbf{u}\mathbf{v} and vprojuv\mathbf{v}-\text{proj}_\mathbf{u}\mathbf{v} for u=(34)\mathbf{u}=\begin{pmatrix}3\\4\end{pmatrix}, v=(51)\mathbf{v}=\begin{pmatrix}5\\1\end{pmatrix}. Verify that the remainder is orthogonal to u\mathbf{u}.

EXERCISE 11.2

Step 1: normalise v1\mathbf{v}_1 to get q1\mathbf{q}_1. Step 2: subtract the q1\mathbf{q}_1-projection from v2\mathbf{v}_2, then normalise. Check that q1q2=0\mathbf{q}_1\cdot\mathbf{q}_2=0.

v1=(11)\mathbf{v}_1=\begin{pmatrix}1\\1\end{pmatrix}, v2=(20)\mathbf{v}_2=\begin{pmatrix}2\\0\end{pmatrix}.

q1=12(11)\mathbf{q}_1 = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix}.

v2,q1=12(2+0)=2\langle\mathbf{v}_2,\mathbf{q}_1\rangle = \frac{1}{\sqrt{2}}(2+0)=\sqrt{2}.

u2=(20)212(11)=(20)(11)=(11)\mathbf{u}_2 = \begin{pmatrix}2\\0\end{pmatrix} - \sqrt{2}\cdot\frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix} = \begin{pmatrix}2\\0\end{pmatrix}-\begin{pmatrix}1\\1\end{pmatrix}=\begin{pmatrix}1\\-1\end{pmatrix}.

u2=1+1=2\|\mathbf{u}_2\|=\sqrt{1+1}=\sqrt{2}, so q2=12(11)\mathbf{q}_2=\frac{1}{\sqrt{2}}\begin{pmatrix}1\\-1\end{pmatrix}.

Verify: q1q2=12(11+1(1))=0\mathbf{q}_1\cdot\mathbf{q}_2=\frac{1}{2}(1\cdot1+1\cdot(-1))=0 ✓. q1=q2=1\|\mathbf{q}_1\|=\|\mathbf{q}_2\|=1 ✓.

Q=12(1111)Q=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}, R=(2202)R=\begin{pmatrix}\sqrt{2}&\sqrt{2}\\0&\sqrt{2}\end{pmatrix} (since r11=v1=2r_{11}=\|\mathbf{v}_1\|=\sqrt{2}, r12=v2,q1=2r_{12}=\langle\mathbf{v}_2,\mathbf{q}_1\rangle=\sqrt{2}, r22=u2=2r_{22}=\|\mathbf{u}_2\|=\sqrt{2}).

Apply Gram-Schmidt to v1=(11)\mathbf{v}_1=\begin{pmatrix}1\\1\end{pmatrix}, v2=(20)\mathbf{v}_2=\begin{pmatrix}2\\0\end{pmatrix} to produce an orthonormal basis {q1,q2}\{\mathbf{q}_1,\mathbf{q}_2\}. Write the resulting QR decomposition of A=(1210)A=\begin{pmatrix}1&2\\1&0\end{pmatrix}.

EXERCISE 11.3

Run the full Gram-Schmidt: normalise v1\mathbf{v}_1; orthogonalise v2\mathbf{v}_2 against q1\mathbf{q}_1; orthogonalise v3\mathbf{v}_3 against both q1\mathbf{q}_1 and q2\mathbf{q}_2. Normalise each step.

v1=(100)\mathbf{v}_1=\begin{pmatrix}1\\0\\0\end{pmatrix}: q1=(100)\mathbf{q}_1=\begin{pmatrix}1\\0\\0\end{pmatrix} (already a unit vector).

v2=(110)\mathbf{v}_2=\begin{pmatrix}1\\1\\0\end{pmatrix}: v2,q1=1\langle\mathbf{v}_2,\mathbf{q}_1\rangle=1. u2=(110)1(100)=(010)\mathbf{u}_2=\begin{pmatrix}1\\1\\0\end{pmatrix}-1\cdot\begin{pmatrix}1\\0\\0\end{pmatrix}=\begin{pmatrix}0\\1\\0\end{pmatrix}. q2=(010)\mathbf{q}_2=\begin{pmatrix}0\\1\\0\end{pmatrix}.

v3=(111)\mathbf{v}_3=\begin{pmatrix}1\\1\\1\end{pmatrix}: v3,q1=1\langle\mathbf{v}_3,\mathbf{q}_1\rangle=1, v3,q2=1\langle\mathbf{v}_3,\mathbf{q}_2\rangle=1.

u3=(111)(100)(010)=(001)\mathbf{u}_3=\begin{pmatrix}1\\1\\1\end{pmatrix}-\begin{pmatrix}1\\0\\0\end{pmatrix}-\begin{pmatrix}0\\1\\0\end{pmatrix}=\begin{pmatrix}0\\0\\1\end{pmatrix}. q3=(001)\mathbf{q}_3=\begin{pmatrix}0\\0\\1\end{pmatrix}.

Q=I3Q=I_3 — the input vectors are already in the direction of the standard basis.

R=(111011001)R=\begin{pmatrix}1&1&1\\0&1&1\\0&0&1\end{pmatrix} (projection coefficients: r11=r22=r33=1r_{11}=r_{22}=r_{33}=1, r12=1r_{12}=1, r13=1r_{13}=1, r23=1r_{23}=1).

Apply Gram-Schmidt to v1=(100)\mathbf{v}_1=\begin{pmatrix}1\\0\\0\end{pmatrix}, v2=(110)\mathbf{v}_2=\begin{pmatrix}1\\1\\0\end{pmatrix}, v3=(111)\mathbf{v}_3=\begin{pmatrix}1\\1\\1\end{pmatrix} and write the resulting QR decomposition of the 3×33\times3 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}\text{span}\{\mathbf{q}_1,\ldots,\mathbf{q}_k\}=\text{span}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\} by induction.

Independence of {q1,,qk}\{\mathbf{q}_1,\ldots,\mathbf{q}_k\}: By construction, qi,qj=0\langle\mathbf{q}_i,\mathbf{q}_j\rangle=0 for iji\neq j and qi=10\|\mathbf{q}_i\|=1\neq0. Suppose iciqi=0\sum_i c_i\mathbf{q}_i=\mathbf{0}. Take the inner product with qj\mathbf{q}_j: iciqi,qj=cj1+ijci0=cj=0\sum_i c_i\langle\mathbf{q}_i,\mathbf{q}_j\rangle = c_j\cdot1 + \sum_{i\neq j}c_i\cdot0 = c_j = 0. So all cj=0c_j=0 — linearly independent.

Same span: Induction on kk. Base: span{q1}=span{v1}\text{span}\{\mathbf{q}_1\}=\text{span}\{\mathbf{v}_1\} since q1=v1/v1\mathbf{q}_1=\mathbf{v}_1/\|\mathbf{v}_1\|. Inductive step: qk=(vki<kvk,qiqi)/\mathbf{q}_k = (\mathbf{v}_k - \sum_{i<k}\langle\mathbf{v}_k,\mathbf{q}_i\rangle\mathbf{q}_i)/\|\cdot\| is a linear combination of vk\mathbf{v}_k and q1,,qk1\mathbf{q}_1,\ldots,\mathbf{q}_{k-1}, which by inductive hypothesis lie in span{v1,,vk1}\text{span}\{\mathbf{v}_1,\ldots,\mathbf{v}_{k-1}\}. So qkspan{v1,,vk}\mathbf{q}_k\in\text{span}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\}. Conversely, vk=ukqk+i<kvk,qiqispan{q1,,qk}\mathbf{v}_k = \|\mathbf{u}_k\|\mathbf{q}_k+\sum_{i<k}\langle\mathbf{v}_k,\mathbf{q}_i\rangle\mathbf{q}_i \in \text{span}\{\mathbf{q}_1,\ldots,\mathbf{q}_k\}.

Prove that the Gram-Schmidt output {q1,,qk}\{\mathbf{q}_1,\ldots,\mathbf{q}_k\} (a) is linearly independent and (b) spans the same space as {v1,,vk}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\}. Use properties of inner products and induction.

EXERCISE 11.5

In QR, the diagonal entries rkk=ukr_{kk} = \|\mathbf{u}_k\|. A diagonal entry of RR is zero     \iff uk=0\|\mathbf{u}_k\|=0     \iff vk\mathbf{v}_k is in the span of v1,,vk1\mathbf{v}_1,\ldots,\mathbf{v}_{k-1}     \iff the columns of AA are linearly dependent.

If columns of AA are linearly independent: vkspan{v1,,vk1}\mathbf{v}_k \notin \text{span}\{\mathbf{v}_1,\ldots,\mathbf{v}_{k-1}\} for all kk, so uk0\mathbf{u}_k\neq\mathbf{0} for all kk, so rkk=uk>0r_{kk}=\|\mathbf{u}_k\|>0 — all diagonal entries are positive.

If some rkk=0r_{kk}=0: then uk=0\|\mathbf{u}_k\|=0, meaning vk=i=1k1vk,qiqi\mathbf{v}_k = \sum_{i=1}^{k-1}\langle\mathbf{v}_k,\mathbf{q}_i\rangle\mathbf{q}_ivk\mathbf{v}_k is a linear combination of v1,,vk1\mathbf{v}_1,\ldots,\mathbf{v}_{k-1}, so the columns are linearly dependent.

Therefore: AA has linearly independent columns     \iff all diagonal entries of RR are nonzero     \iff RR is invertible. This gives a clean test for column independence from the QR factorisation.

Prove that the diagonal entries rkkr_{kk} of RR in the QR decomposition are all nonzero if and only if the columns of AA are linearly independent. What does a zero diagonal entry in RR reveal about the columns of AA?

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.

f1=(0.030.010.050.02)\mathbf{f}_1=\begin{pmatrix}0.03\\0.01\\0.05\\0.02\end{pmatrix} (market), f2=(0.020.030.010.04)\mathbf{f}_2=\begin{pmatrix}0.02\\0.03\\0.01\\0.04\end{pmatrix} (value).

f12=0.0009+0.0001+0.0025+0.0004=0.0039\|\mathbf{f}_1\|^2 = 0.0009+0.0001+0.0025+0.0004=0.0039.

f2,f1=0.0006+0.0003+0.0005+0.0008=0.0022\langle\mathbf{f}_2,\mathbf{f}_1\rangle = 0.0006+0.0003+0.0005+0.0008=0.0022.

Projection coefficient: 0.00220.00390.564\frac{0.0022}{0.0039}\approx0.564.

Orthogonalised value factor: g2=f20.564f1=(0.020.0170.030.0060.010.0280.040.011)(0.0030.0240.0180.029)\mathbf{g}_2=\mathbf{f}_2-0.564\mathbf{f}_1=\begin{pmatrix}0.02-0.017\\0.03-0.006\\0.01-0.028\\0.04-0.011\end{pmatrix}\approx\begin{pmatrix}0.003\\0.024\\-0.018\\0.029\end{pmatrix}.

The original value factor f2\mathbf{f}_2 contains a market component (the projection). After removing it, g2\mathbf{g}_2 is the pure value signal — market-neutral. Its correlation with f1\mathbf{f}_1 is now exactly zero. Regression of returns on (f1,g2)(\mathbf{f}_1, \mathbf{g}_2) 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\mathbf{f}_1=(0.03, 0.01, 0.05, 0.02)^T and value-factor returns f2=(0.02,0.03,0.01,0.04)T\mathbf{f}_2=(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\mathbf{g}_2 that is uncorrelated with the market. Interpret what the orthogonalisation removes.


06 · Chapter Summary

ConceptFormula / Rule
Projection onto u\mathbf{u}projuv=v,uu,uu\text{proj}_\mathbf{u}\mathbf{v} = \frac{\langle\mathbf{v},\mathbf{u}\rangle}{\langle\mathbf{u},\mathbf{u}\rangle}\mathbf{u}
Orthogonal remaindervprojuvu\mathbf{v}-\text{proj}_\mathbf{u}\mathbf{v}\perp\mathbf{u}
Gram-Schmidt step jjuj=vji<jvj,qiqi\mathbf{u}_j=\mathbf{v}_j-\sum_{i<j}\langle\mathbf{v}_j,\mathbf{q}_i\rangle\mathbf{q}_i; qj=uj/uj\mathbf{q}_j=\mathbf{u}_j/\|\mathbf{u}_j\|
Fails whenInput is linearly dependent; uj=0\mathbf{u}_j=\mathbf{0} for some jj
QR decompositionA=QRA=QR; QQ has orthonormal cols; RR upper triangular
RR diagonal entriesrkk=uk>0    r_{kk}=\|\mathbf{u}_k\|>0 \iff columns of AA are independent
Span preservedspan{q1,,qk}=span{v1,,vk}\text{span}\{\mathbf{q}_1,\ldots,\mathbf{q}_k\}=\text{span}\{\mathbf{v}_1,\ldots,\mathbf{v}_k\}
Quant useOrthogonal 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.