Principal angles between subspaces
Companion to the foundations page Principal angles between subspaces. Everything here lives in $\mathbb R^3$ so the subspaces can be drawn: lines (dimension 1) and planes (dimension 2). Drag the 3-D view to turn it.
Two lines meet at one angle. A line and a plane meet at one angle (the line against its own shadow in the plane). Two planes have two angles, and in $\mathbb R^3$ the first is always $0^\circ$, because two planes through the origin share a line. The number of angles is $\min(p,q)$, the smaller dimension.
1. Build two subspaces and read their angles
2. The SVD recipe: the angles are in $Q_U^\top Q_V$, whatever basis you pick
The notes' boxed formula says the singular values of $Q_U^\top Q_V$ are $\cos\theta_i$, where the columns of $Q_U,Q_V$ are any orthonormal bases of the two subspaces. Spin the basis inside each subspace and watch the matrix change while its singular values stay put.
3. The accuracy trap: cosines forget small angles
Take two lines in the plane at a tiny angle $\theta$: $u=(1,0)$, $v=(\cos\theta,\sin\theta)$. Recover $\theta$ two ways in ordinary double-precision arithmetic: from the cosine, $\arccos(u^\top v)$, and from the sine, $\arcsin\lVert (I-P_U)v\rVert$.