Post · 11 min read· pp. 1245–1250

CS294 Lecture 0: Linear Algebra Review

In which we review linear algebra prerequisites.

The following background from linear algebra will be sufficient for the sake of this course: to know what is an eigenvalue and an eigenvector, to know that real symmetric matrices have real eigenvalues and their real eigenvectors are orthogonal, and to know the variational characterization of eigenvalues.

1. Basic Definitions

If x=a+ib{x=a+ib} is a complex number, then we let xˉ=a−ib{\bar x = a- ib} denote its conjugate. Note that a complex number x{x} is real if and only if x=xˉ{x = \bar x}. If M∈Cm×n{M \in {\mathbb C}^{m \times n}} is a matrix, then M∗{M^*} denotes the conjugate transpose of M{M}, that is, (M∗)i,j=Mj,i‾{(M^*)_{i,j} = \overline{M_{j,i}}}. If the entries of M{M} are real, then M∗=MT{M^* = M^T}, where MT{M^T} is the transpose of M{M}, that is, the matrix such that (MT)i,j=Mj,i{(M^T)_{i,j} = M_{j,i}}.

We say that a matrix M{M} is Hermitian if M=M∗{M = M^*}. In particular, real symmetric matrices are Hermitian.

If x,y∈Cn{{\bf x},{\bf y} \in {\mathbb C}^n} are two vectors, then their inner product is defined as

⟨v,w⟩:=v∗w=∑ivi‾⋅wi     (1)\displaystyle \langle {\bf v},{\bf w} \rangle := {\bf v}^* {\bf w} = \sum_i \overline{v_i} \cdot w_i \ \ \ \ \ (1)

Notice that, by definition, we have ⟨v,w⟩=(⟨w,v⟩)∗{\langle {\bf v}, {\bf w} \rangle = (\langle {\bf w}, {\bf v} \rangle)^*} and ⟨v,v⟩=∣∣v∣∣2{\langle {\bf v}, {\bf v} \rangle = || {\bf v} ||^2}. Note also that, for two matrices A,B{A,B}, we have (A⋅B)∗=B∗⋅A∗{(A \cdot B)^* = B^* \cdot A^*}, and that for every matrix M{M} and every two vectors x{{\bf x}}, y{{\bf y}}, we have

⟨Mx,y⟩=x∗M∗y=⟨x,M∗y⟩\displaystyle \langle M {\bf x} , {\bf y} \rangle = {\bf x}^* M^* {\bf y} = \langle {\bf x} , M^* {\bf y} \rangle

If M∈Cn×n{M\in {\mathbb C}^{n \times n}} is a square matrix, λ∈C{\lambda \in {\mathbb C}} is a scalar, v∈Cn−{0}{{\bf v} \in {\mathbb C}^n - \{ {\bf {0}} \}} is a non-zero vector and we have

Mv=λv     (2)\displaystyle M {\bf v} = \lambda {\bf v} \ \ \ \ \ (2)

then we say that λ{\lambda} is an eigenvalue of M{M} and that v{{\bf v}} is eigenvector of M{M} corresponding to the eigenvalue λ{\lambda}.

2. The Spectral Theorem

We want to prove

Theorem 1 (Spectral Theorem) Let M∈Rn×n{M\in {\mathbb R}^{n\times n}} be a symmetric matrix with real-valued entries, then there are n{n} real numbers (not necessarily distinct) λ1,…,λn{\lambda_1,\ldots,\lambda_n} and n{n} orthonormal real vectors x1,…,xn{{\bf x}_1,\ldots,{\bf x}_n}, xi∈Rn{{\bf x}_i \in {\mathbb R}^n} such that xi{{\bf x}_i} is an eigenvector of λi{\lambda_i}.

Assuming the fundamental theorem of algebra (that every polynomial has a complex root) and basic properties of the determinant, the cleanest proof of the spectral theorem is to proceed by induction on n{n}, and to show that M{M} must have a real eigenvalue λ1{\lambda_1} with a real eigenvector v1{{\bf v}_1}, and to show that M{M} maps vectors orthogonal to v1{{\bf v}_1} to vectors orthogonal to v1{{\bf v}_1}. Then one applies the inductive hypothesis to M{M} restricted to the (n−1){(n-1)}-dimensional space of vectors orthogonal to v1{{\bf v}_1} and one recovers the remaining (n−1){(n-1)} eigenvalues and eigenvectors.

The cleanest way to formalize the above proof is to give all definitions and results in terms of linear operators T:X→X{T: X \rightarrow X} where X{X} is an arbitrary vector space over the reals. This way, however, we would be giving several definitions that we would never use in the future, so, instead, the inductive proof will use a somewhat inelegant change of basis to pass from M{M} to an (n−1)×(n−1){(n-1) \times (n-1)} matrix M′{M'}.

We begin by showing that a real symmetric matrix has real eigenvalues and eigenvectors.

Theorem 2 If M∈Rn×n{M\in {\mathbb R}^{n\times n}} is symmetric, then there is a real eigenvalue λ∈R{\lambda \in {\mathbb R}} and a real eigenvector v∈Rn{{\bf v} \in {\mathbb R}^n} such that Mv=λv{M {\bf v} = \lambda {\bf v}}.

We begin by noting that every matrix has a complex eigenvalue.

Lemma 3 For every matrix M∈Cn×n{M\in {\mathbb C}^{n \times n}}, there is an eigenvalue λ∈C{\lambda \in {\mathbb C}} and an eigenvector v∈Cn{{\bf v} \in {\mathbb C}^n} such that Mv=λv{M {\bf v} = \lambda {\bf v}}.

Proof: Note that λ{\lambda} is an eigenvalue for M{M} if and only if

∃x≠0. (M−λI)x=0\displaystyle \exists {\bf x} \neq {\bf 0}. \ ( M - \lambda I ) {\bf x} = {\bf 0}

which is true if and only if the rows of M−λI{M-\lambda I} are not linearly independent, which is true if and only if

det⁡(M−λI)=0\displaystyle \det (M - \lambda I ) = 0

Now note that the mapping t→det⁡(M−tI){t \rightarrow \det (M - t I )} is a univariate polynomial of degree n{n} in t{t}, and so it must have a root λ{\lambda} by the fundamental theorem of algebra. □\Box

Next we show that if M{M} is real and symmetric, then its eigenvalues are real.

Lemma 4 If M{M} is Hermitian, then, for every x{{\bf x}} and y{{\bf y}},

⟨Mx,y⟩=⟨x,My⟩\displaystyle \langle M {\bf x} , {\bf y} \rangle = \langle {\bf x} , M {\bf y} \rangle

Proof:

⟨Mx,y⟩=⟨x,M∗y⟩=⟨x,My⟩\displaystyle \langle M {\bf x} , {\bf y} \rangle = \langle {\bf x} , M^* {\bf y} \rangle = \langle {\bf x} , M {\bf y} \rangle

□\Box

Lemma 5 If M{M} is Hermitian, then all the eigenvalues of M{M} are real.

Proof: Let M{M} be an Hermitian matrix and let λ{\lambda} be a scalar and x{{\bf x}} be a non-zero vector such that Mx=λx{M {\bf x} = \lambda {\bf x}}. We will show that λ=λ∗{\lambda = \lambda^*}, which implies that λ{\lambda} is a real number.

We note that

⟨Mx,x⟩=⟨λx,x⟩=λ∗∣∣x∣∣2\displaystyle \langle M{\bf x}, {\bf x} \rangle = \langle \lambda {\bf x}, {\bf x} \rangle = \lambda^* ||x||^2

and

⟨x,Mx⟩=⟨x,λx⟩=λ∣∣x∣∣2\displaystyle \langle {\bf x}, M {\bf x} \rangle = \langle {\bf x}, \lambda {\bf x} \rangle = \lambda ||x||^2

and by the fact that ⟨Mx,x⟩=⟨x,Mx⟩{\langle M{\bf x}, {\bf x} \rangle = \langle {\bf x}, M{\bf x} \rangle} , we have λ=λ∗{\lambda = \lambda^*}. □\Box

In order to prove Theorem 2, it remains to argue that, for a real eigenvalue of a real symmetric matrix, we can find a real eigenvector.

Proof: } Let M∈Rn×n{M \in {\mathbb R}^{n \times n}} be a real symmetric matrix, then M{M} has a real eigenvalue λ{\lambda} and a (possibly complex valued) eigenvector z=x+iy{{\bf z} = {\bf x} + i {\bf y}}, where x{{\bf x}} and y{{\bf y}} are real vectors. We have

Mx+iMy=λx+iλy\displaystyle M {\bf x} + i M {\bf y} = \lambda {\bf x} + i \lambda {\bf y}

from which (recalling that the entries of M{M} and the scalar λ{\lambda} are real) it follows that Mx=λx{M {\bf x} = \lambda {\bf x}} and that My=λy{M {\bf y} = \lambda {\bf y}}; since x{{\bf x}} and y{{\bf y}} cannot both be zero, it follows that λ{\lambda} has a real eigenvector. □\Box

We are now ready to prove the spectral theorem

Proof: We proceed by induction on n{n}. The case n=1{n=1} is trivial.

Assume that the statement is true for dimension n−1{n-1}. Let λ1{\lambda_1} be a real eigenvalue of M{M} and x1{{\bf x}_1} be a real eigenvector λ1{\lambda_1}.

Now we claim that for every vector y{{\bf y}} that is orthogonal to x1{{\bf x}_1}, then My{M{\bf y}} is also orthogonal to x1{{\bf x}_1}. Indeed, the inner product of My{M{\bf y}} and x1{{\bf x}_1} is

⟨x1,My⟩=⟨Mx1,y⟩=⟨λx1,y⟩=0\displaystyle \langle {\bf x}_1, M{\bf y} \rangle = \langle M {\bf x}_1 , {\bf y} \rangle = \langle \lambda {\bf x}_1,{\bf y} \rangle = 0

Let X{X} be the n−1{n-1}-dimensional subspace of Rn{{\mathbb R}^n} that contains all the vectors orthogonal to x1{{\bf x}_1}. We want to apply the inductive hypothesis to M{M} restricted to X{X}; we cannot literally do that, because the theorem is not stated in terms of arbitrary linear operators over vector spaces, so we will need to do that by fixing an appropriate basis for X{X}.

let B∈Rn×(n−1){B \in {\mathbb R}^{n \times (n-1)}} be a matrix that computes a bijective map from Rn−1{{\mathbb R}^{n-1}} to X{X}. (If b1,…,bn−1{{\bf b}_1, \ldots,{\bf b}_{n-1}} is an orthonormal basis for X{X}, then B{B} is just the matrix whose columns are the vectors bi{{\bf b}_i}.) Let also B′∈R(n−1)×n{B' \in {\mathbb R}^{(n-1) \times n}} be the matrix such that, for every y∈X{{\bf y} \in X}, BB′y=y{BB' {\bf y} = {\bf y}}. (We can set B′=BT{B' = B^T} where B{B} is as described above.) We apply the inductive hypothesis to the matrix

M′:=B′MB∈R(n−1)×(n−1)\displaystyle M' := B'MB \in {\mathbb R}^{(n-1) \times (n-1)}

and we find eigenvalues λ2,…,λn{\lambda_2,\ldots,\lambda_n} and orthonormal eigenvectors y2,…,yn{{\bf y}_2,\ldots,{\bf y}_n} for M′{M'}.

For every i=2,…,n{i=2,\ldots,n}, we have

B′MByi=λiyi\displaystyle B'MB {\bf y}_i = \lambda_i {\bf y}_i

and so

BB′MByi=λiByi\displaystyle BB'MB{\bf y}_i = \lambda_i B {\bf y}_i

Since Byi{B{\bf y}_i} is orthogonal to x1{{\bf x}_1}, it follows that MByi{MB{\bf y}_i} is also orthogonal to x1{{\bf x}_1}, and so BB′MByi=MByi{BB'MB{\bf y}_i = MB{\bf y}_i}, so we have

MByi=λiByi\displaystyle MB{\bf y}_i = \lambda_i B{\bf y}_i

and, defining xi:=Byi{{\bf x}_i := B{\bf y}_i}, we have

Mxi=λixi\displaystyle M {\bf x}_i = \lambda_i {\bf x}_i

Finally, we observe that the vectors xi{{\bf x}_i} are orthogonal. By construction, x1{{\bf x}_1} is orthogonal to x2,…,xn{{\bf x}_2,\ldots,{\bf x}_n}, and, for every 2≤i<j≤n{2 \leq i < j \leq n}, we have that

⟨xi,xj⟩=⟨Byi,Byj⟩=⟨yi,BTByj⟩=⟨yi,yj⟩=0\displaystyle \langle {\bf x}_i , {\bf x}_j \rangle = \langle B {\bf y}_i , B {\bf y}_j \rangle = \langle {\bf y}_i , B^T B {\bf y} _j \rangle = \langle {\bf y}_i , {\bf y}_j \rangle = 0

We have not verified that the vectors xi{{\bf x}_i} have norm 1 (which is true), but we can scale them to have norm 1 if not. □\Box

3. Variational Characterization of Eigenvalues

We conclude these notes with the variational characterization of eigenvalues for real symmetric matrices.

Theorem 6 Let M∈Rn×n{M\in {\mathbb R}^{n \times n}} be a symmetric matrix, and λ1≤λ2≤⋯λn{\lambda_1 \leq \lambda_2 \leq \cdots \lambda_n} be the eigenvalues of M{M} in non-increasing order. Then

λk=min⁡k−dim X   max⁡x∈X−{0}  xTMxxTx\displaystyle \lambda_k = \min_{k-{\rm dim} \ X} \ \ \ \max_{{\bf x} \in X - \{ {\bf 0} \} } \ \ \frac{ {\bf x}^T M {\bf x}}{{\bf x}^T {\bf x}}

The quantity xTMxxTx{\frac { {\bf x}^T M {\bf x}}{{\bf x}^T {\bf x}} } is called the Rayleigh quotient of x{{\bf x}} with respect to M{M}, and we will denote it by RM(x){R_M({\bf x})}.

Proof: Let v1,…,vn{{\bf v}_1,\ldots,{\bf v}_n} be orthonormal eigenvectors of the eigenvalues λ1,…,λn{\lambda_1,\ldots,\lambda_n}, as promised by the spectral theorem. Consider the k{k}-dimensional space spanned by v1,…,vk{{\bf v}_1, \ldots,{\bf v}_k}. For every vector x=∑i=1kaivi{{\bf x} = \sum_{i=1}^k a_i {\bf v}_i} in such a space, the numerator of the Rayleigh quotient is

∑i,jaiajviTMvj=∑i,jaiajλjviTvj=∑i=1kλiai2≤λk⋅∑i=1kai2\displaystyle \sum_{i,j} a_i a_j {\bf v}_i^T M {\bf v}_j = \sum_{i,j} a_i a_j \lambda_j {\bf v}_i^T {\bf v}_j = \sum_{i=1}^k \lambda_i a_i^2 \leq \lambda_k \cdot \sum_{i=1}^k a_i^2

The denominator is clearly ∑i=1kaj2{\sum_{i=1}^k a_j^2}, and so RM(x)≤λk{R_M({\bf x}) \leq \lambda_k}. This shows that

λk≥min⁡k−dim X   max⁡x∈X−{0}  xTMxxTx\displaystyle \lambda_k \geq \min_{k-{\rm dim} \ X} \ \ \ \max_{{\bf x} \in X - \{ {\bf 0} \}} \ \ \frac{ {\bf x}^T M {\bf x}}{{\bf x}^T {\bf x}}

For the other direction, let X{X} be any k{k}-dimensional space: we will show that X{X} must contain a vector of Rayleigh quotient ≥λk{\geq \lambda_k}. Let S{S} be the span of vk,…,vn{{\bf v}_k,\ldots,{\bf v}_n}; since S{S} has dimension n−k+1{n-k+1} and X{X} has dimension k{k}, they must have some non-zero vector in common. Let x{{\bf x}} be one such vector, and let us write x=∑i=knaivi{{\bf x} = \sum_{i=k}^n a_i {\bf v}_i}. The numerator of the Rayleigh quotient of x{{\bf x}} is

∑i=knλiai2≥λk∑iai2\displaystyle \sum_{i=k}^n \lambda_i a_i^2 \geq \lambda_k \sum_i a_i^2

and the denominator is ∑iai2{\sum_i a_i^2}, so RM(x)≥λk{R_M({\bf x}) \geq \lambda_k}. □\Box

We have the following easy consequence.

Fact 7 If λ1{\lambda_1} is the smallest eigenvalue of a real symmetric matrix M{M}, then

λ1=min⁡x≠0RM(x)\displaystyle \lambda_1 = \min_{{\bf x} \neq {\bf 0}} R_M({\bf x})

Furthermore, every minimizer is an eigenvector of λ1{\lambda_1}.

Proof: The identity is the k=1{k=1} case of the previous theorem. For the furthermore part, let λ1≤⋯λn{\lambda_1 \leq \cdots \lambda_n} be the list of eigenvalues of M{M} in non-decreasing order, and v1,…,vn{{\bf v}_1,\ldots,{\bf v}_n} be corresponding eigenvectors. If x=∑iaivi{{\bf x} = \sum_i a_i {\bf v}_i} is any vector, then

RM(x)=∑iλiai2∑iai2\displaystyle R_M( {\bf x} ) = \frac { \sum_i \lambda_i a_i^2}{\sum_i a_i^2}

If RM(x)=λ1{R_M({\bf x}) = \lambda_1}, then ai=0{a_i = 0} for every i{i} such that λi>λ1{\lambda_i > \lambda_1}, that is, x{{\bf x}} is a linear combination of eigenvectors of λ1{\lambda_1}, and hence it is an eigenvector of λ1{\lambda_1}. □\Box

Fact 8 If λn{\lambda_n} is the largest eigenvalue of a real symmetric matrix M{M}, then

λn=max⁡x≠0RM(x)\displaystyle \lambda_n = \max_{{\bf x} \neq {\bf 0}} R_M({\bf x})

Furthermore, every maximizer is an eigenvector of λn{\lambda_n}.

Proof: Apply Fact 7 to the matrix −M{-M}. □\Box

Fact 9 If λ1{\lambda_1} is the smallest eigenvalue of a real symmetric matrix M{M}, and x1{{\bf x}_1} is an eigenvector of λ1{\lambda_1}, then

λ2=min⁡x≠0, x⊥x1   RM(x)\displaystyle \lambda_2 = \min_{{\bf x} \neq {\bf 0},\ {\bf x} \perp {\bf x}_1} \ \ \ R_M({\bf x})

Furthermore, every minimizer is an eigenvector of λ2{\lambda_2}.

Proof: A more conceptual proof would be to consider the restriction of M{M} to the space orthogonal to x1{{\bf x}_1}, and then apply Fact 7 to such a linear operator. But, since we have not developed the theory for general linear operators, we would need to explicitly reduce to an (n−1){(n-1)}-dimensional case via a projection operator as in the proof of the spectral theorem.

Instead, we will give a more hands-on proof. Let λ1≤λ2≤⋯λn{\lambda_1 \leq \lambda_2 \leq \cdots \lambda_n} be the list of eigenvalues of M{M}, with multiplicities, and v1,…,vn{{\bf v}_1,\ldots,{\bf v}_n} be orthonormal vectors as given by the spectral theorem. We may assume that v1=x1{{\bf v}_1 = {\bf x}_1}, possibly by changing the orthonormal basis of the eigenspace of λ1{\lambda_1}. For every vector x=∑i=2kaivi{{\bf x} = \sum_{i=2}^k a_i {\bf v}_i } orthogonal to v1{{\bf v}_1}, its Rayleigh quotient is

RM(x)=∑i=2nλiai2∑iai2≥λ2\displaystyle R_M({\bf x}) = \frac { \sum_{i=2}^n \lambda_i a_i^2}{\sum_i a_i^2} \geq \lambda_2

and the minimum is achieved by vectors x{{\bf x}} such that ai=0{a_i = 0} for every λi>λ2{\lambda_i > \lambda_2}, that is, for vectors x{{\bf x}} which are linear combinations of the eigenvectors of λ2{\lambda_2}, and so every minimizer is an eigenvector of λ2{\lambda_2}. □\Box