In Section 17.5, we foreshadowed how the signature of A encodes its behavior.
Let's get to the punchline of this foreshadowing.
Definition (Quadric Surface). A quadric surface in Rn is a subset of the form {x∈Rn∣x⊤Ax+b⊤x+c=0} for some symmetric matrix A∈Rn×n, b∈Rn, and c∈R.
Example. We already know the n=1 and n=2 cases from high school.
In n=1, quadric surfaces are either pairs of points, single points, the empty set, or all of R.
In n=2, quadric surfaces are conics: ellipses, hyperbolas, and the degeneracies.
We now use a special case of the Spectral Theorem in the context of R.
Theorem. (Spectral Theorem over Rn) If A∈Rn×n is symmetric, its eigenvectors form an orthonormal basis.
In other words, there exists some T∈On(R) such that T⊤AT=Λ, where Λ is diagonal. Thus,
⟺⟺⟺x⊤Ax+b⊤x+c=0(T−1x)⊤(T⊤AT)(T−1x)+(T⊤b)⊤(T−1x)+c=0y⊤Λy+(T⊤b)⊤y+c=0(λ1y12+⋯+λnyn2)+(b1′y1+⋯+bn′yn)+c=0 by plain computation where y=T−1x
The point is that y=T−1x represents an orthonormal change of basis because T∈On(R). Therefore,
Theorem. (Quadric Classification) All quadric surfaces, up to an orthonormal change of basis, look like:
{y∈Rn:(i=1∑nλiyi2)+(i=1∑nbiyi)+c=0}
Furthermore, if detA=0, then each λi is nonzero, so we can complete the square, leaving ∑i=1nλiyi2=k for some constant k. When k=0, we can also scale, yielding…
Theorem. (Non-Singular Quadric Classification) All nonsingular quadric surfaces—those with detA=0 and k=0—are affinely equivalent to:
{y∈Rn:i=1∑nλiyi2=1}, where each λi is either +1 or −1.
Some corollaries of these observations:
There are only n+1 non-singular quadric surfaces in Rn.
Parabolas are a degeneracy! They correspond to a singular choice of A.
Almost all randomly chosen R3 quadric surfaces (say, 67xy+41z2−14yz+34x=1, for example) are affinely equivalent to one of the following: x2+y2+z2=1 or x2+y2−z2=1 or x2−y2−z2=1.
§ Spectral Application #2: Principal Component Analysis
For this section, here's the setup:
Setup. Take n random variables {Xi}i=1n in a column vector X∈Rn. Normalize the Xi so that E[Xi]=0 for all i. (In other words, E[X]=0.)
We'll first build all necessary mathematical foundations, up to the Rayleigh-Ritz theorem.
Definition (Variance, Covariance, Covariance Matrix). Let A and B be random variables in X.
The variance of A is Var(A):=E[A2]−E[A]2. When A is normalized so that E[A]=0, we have Var(A)=E[A2].
The covariance of A and B is Cov(A,B):=E[AB]−E[A]E[B]. When A and B are normalized so that E[A]=E[B]=0, we have Cov(A,B)=E[AB].
The covariance matrix of X is Cov(X):=(Cov(Xi,Xj))i,j. When X is normalized so that E[X]=0, we have Cov(X)=E[XX⊤].
Theorem. (Variance of Linear Combinations) Let M:=Cov(X). Then for any c∈Rn, we have Var(c⊤X)=c⊤Mc.
This is a weighted average of {λi}i=1n, and the maximum possible weighted average is max{λi}i=1n=λ1.
More generally, when c⊥vi for all i<k, we're forced to have αi=0 for all i<k. Then we instead have a weighted average of {λi}i=kn, for which the maximum possible value is λk. ■
Mathematics aside, here's what we wish to do with our random variables {Xi}i=1n from earlier.
Intuition. Many samples from X form a point cloud in Rn. We wish to look at this point cloud from a certain angle—a certain orthonormal basis, perhaps—so that the axes of our orthonormal basis point in “meaningful directions”.
What qualifies as a “meaningful direction”, then? The Rayleigh-Ritz theorem proposes a good candidate.
Theorem. (Rayleigh-Ritz Corollary) Let M be the covariance matrix of X. Then c⊤cVar(c⊤X) is maximized when c is the eigenvector of M with greatest eigenvalue.
Think of our point cloud as a messy ellipsoid centered at the origin. Then the c that maximizes c⊤cVar(c⊤X) will be the c that points along the highest-variance axis of X—that is, the longest axis of the ellipsoid!
In fact, the more general case of Rayleigh-Ritz indicates that the set of all eigenvectors of M will point along orthogonal axes of this ellipsoid! In conclusion,
— Conclusion (PCA) —
Given a point cloud X of data with covariance matrix M, we can identify the most “principal components” of the point cloud by picking out the eigenvectors of M with the greatest eigenvalues.
Naturally, the strategy of using the eigenvectors of M to analyze X is called Principal Component Analysis (PCA).
In the particular context of facial recognition, eigenfaces are a set of eigenvectors whose linear combination with unique coefficients yields distinct faces.
§ Spectral Application #3: Singular Value Decomposition
Here's the setup this time.
Setup. We have n normalized random variables {Xi}i=1n, and we sample each one m times. This gives us a matrix X∈Rm×n, where Xi,j gives the ith sample of Xj.
We'll first state the necessary mathematics, then show its applications, and finally prove the mathematics.
Definition (Sample Covariance). The sample covariance matrix of X is the n×n matrix Cov(X):=m−11X⊤X.
Intuitively, Cov(X)i,j gives the sample covariance of Xi and Xj.
Theorem. (Singular Value Decomposition) Every matrix A∈Rm×n factors in the following way:
A=VΣW⊤ for some V∈Om(R),W∈On(R), and diagonal Σ∈Rm×n.
If Σ has diagonal entries σ1≥σ2≥⋯≥0, then we say {σi} are the singular values of A.
If X factors in this way as X=VΣW⊤ with singular values {σi}, then the sample covariance matrix is:
The way Σ⊤Σ is written above assumes m≥n. If m<n, then the remaining n−m diagonal entries are zeroes.
— Conclusion (SVD on Covariance Matrices) —
Consider a matrix X∈Rm×n of data. Assume m≥n. Factor X as VΣW⊤ with singular values σ1≥σ2≥⋯≥0.
Then Cov(X) has eigenvalues {m−1σi2}i=1n and eigenvectors being the columns of W.
(If m<n, then the remaining n−m eigenvalues are zeroes.)
Some useful diagrams depicting object-level examples of what SVD does.
Some good things to keep in mind while we prove SVD.
For orthogonal matrices V and W, we always have V⊤=V−1 and W⊤=W−1.
Recall A∈Rm×n is a map A:Rn→Rm, so W and V are operators on the domain and codomain, respectively.
Proof: Assume without loss of generality that n≤m. (If instead n≥m, work with A⊤ instead of A.)
We begin by rephrasing our win condition.
Claim. It suffices to find orthonormal bases {v1,…,vm}⊆Rm and {w1,…,wn}⊆Rn and constants {σ1,…,σn} such that Awi=σivi for all i=1,2,…,n.
Proof: Use the {vi}i=1m and {wi}i=1n as columns of V and W, and use the {σi}i=1n as the diagonal of Σ.
To show A=VΣW⊤, it suffices to check that A and VΣW⊤ agree on the images of every element in some basis of the domain Rn. Let's use the basis {wi}i=1n.
(1)A(wi)=σivi by assumption.(2)VΣW⊤(wi)=σivi by computation.
Hooray—they match. □
Observe the following properties of A⊤A∈Rn×n.
Since A⊤A is symmetric, the Spectral theorem says its eigenvectors form an orthonormal basis. Thus, we may take {wi}i=1n to be this orthonormal basis. (This move is forced—why?)
Since A⊤A is positive semidefinite, the eigenvalues {λi}i=1n of A⊤A are nonnegative. Thus, we may take {σi}i=1n to be σi=λi for all i. (This move is forced—why?)
Great! We've already found {wi}i=1n and {σi}i=1n.
For {vi}i=1m, we'll just take vi=σiAwi for i≤n, then fill in the rest arbitrarily (maintaining orthonormality).
Well, it's pretty obvious that Awi=σivi will hold for all i. Now we just need to show {vi}i=1m is orthonormal.
⟨vi,vj⟩=vi⊤vj=σiσjwj⊤A⊤Awi=σiσjwj⊤(σi2wi)=σjσi⟨wj,wi⟩={10 if i=j if i=j
We've checked everything we needed, so we're done. ♣
Well, okay, fine—there's one issue we missed, shown in orange. If σi=0, then vi=σiAwi doesn't make sense. Fortunately, if σi=0, there's an easy fix.
Thus, the constraint Awi=σivi holds trivially—again just pick vi arbitrarily, maintaining orthonormality. ■
Unlike some of our previous “factorization” theorems, this one applies to all matrices!
Remark. Despite how long the above proof is, it's actually extremely motivated—in particular, AA⊤ and A⊤A tell us what V, W, and Σhave to be, and then it remains to check that everything remains consistent.
Hint: It is rumored that the SVD may be useful for Problem Set #10.
§ Linear Groups
We're about to transition to a new topic: embedding groups into geometric objects.
Example. There exists a natural bijection SO2(R)↔S1, where S1 is the unit circle.
The interesting point, however, is that it's surprisingly difficult to embed SO3(R) into a geometric object!
Here are some failed attempts:
Every rotation in SO3(R) can be described by an axis v∈S2 and an angle θ∈S1. Thus, SO3(R)≅S2×S1.
Unfortunately, this “bijection” has a lot of messy non-injectivity! For example, v and −v represent the same axis.
Every rotation in SO3(R) can be described using roll, pitch, and yaw. Thus, SO3(R)≅S1×S1×S1.
When built in real life, this parametrization can cause gimbal lock to occur!
Famously, gimbal lock caused problems on the Apollo 11 Moon mission.
Spoilers: it turns out S3 and the quaternions will be the most natural parametrization of SO3(R).