Skip to content
ImagineWorld

Eigenvalues and Eigenvectors

node_idnode-book_mathematics-of-machine-learning_chapter-06-eigenvalues-and-eigenvectors
node_typechapter_node
schema_profileworld.chapter_node.v1
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
statusactive
chapter_num6
chapter_titleEigenvalues and Eigenvectors
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

So far, we have seen three sides of linear transformations: functions, matrices, and transforms that distort the grid of the underlying vector space. In the Euclidean plane, we saw some examples (Section 4.3) that shed some light on the geometric nature of them.

Following this line of thought, let’s consider the linear transformation given by the matrix

L(U,V ) = {f : U → V | f is linear}

6.1

Since the columns of A are the images of the standard basis vectors e1 = (1,0) and e2 = (0,1), we can visualize the effect of A on Figure 6.1. (Check Section 4.1.1 if you don’t recall this fact.)

This seems to shear, stretch, and rotate the entire grid. However, there are special directions along which A is simply a stretching. For instance, consider the vector u1 = (1,1). By a simple calculation, you can verify that Au1 = 3u1.

Because of the linearity, this means that if a vector x is in span(u1), its image under A is 3x.

PIC

Figure 7.1: Images of the standard basis vectors under the linear transformation given by A

Another one is u2 = (−1,1), where we have Au2 = u2. Thus, any x ∈ span(u2) is left in place.

If we select u1,u2 as our base, the matrix of this transformation is

 ⌊ ⌋ Au ,u = ⌈3 0⌉ , 1 2 0 1

that is, Au1,u2 is diagonal.

PIC

Figure 7.2: Images of u1 = (1,1) and u2 = (−1,1) under the linear transformation given by A

We love diagonal matrices in practice because multiplication with a diagonal matrix is much faster, as it requires O(n) operations, opposed to O(n2).

Is this a general phenomena? Are these even useful? The answer is yes to both questions. What we have just seen is formalized by the concept of eigenvalues and eigenvectors. The terminology originates from the german word “eigen” meaning “own,” resulting in one of the ugliest naming conventions in mathematics.

Definition 23. (Eigenvalues and eigenvectors)

Let f : V → V be an arbitrary linear transformation. We say that the λ scalar and the x ∈V ∖{0} nonzero vector is an eigenvalue-eigenvector pair of f if f(x) = λx holds.

day-mode Bookmark

Although we have formally defined eigenvalues and eigenvectors for linear transformations, we often talk about them in context of matrices. (Because, as we have seen, matrices and linear transformations are two faces of the same coin.) Let’s start by translating the definition into the language of matrices.

If A ∈ℝn×n is a matrix, Definition 23 translates to the following: the scalar λ and the vector x ∈ℝ ∖{0} is an eigenvalue-eigenvector pair of the matrix if

Ax = λx

(6.2)

holds. This can be simplified: as the linear transformation x→λx corresponds to the matrix λI, (6.2) is equivalent to

(A − λI)x = 0

(6.3)

If you recall Chapter 4, Section 4.1.1, where we learned how matrices arise from linear transformations, you might ask the question: won’t the eigenvalues depend on the choice of the matrix?

The following theorem states that this is not the case: the eigenvalues of a linear transformation and its matrices are the same.

Theorem 36. (Eigenvalues of similar matrices)

Let A,B ∈ℝn×n be two similar matrices, that is, suppose that there exists an invertible T ∈ℝn×n such that B = T−1AT. Then, if Ax = λx holds for some scalar λ and vector x ∈ℝn,

then

 ′ ′ Bx = λx

holds for some x′∈ℝn as well.

Proof. Let’s massage the eigenvalue (6.3) a bit! We have

 −1 (A − λI)x = (A − λT T )x = T (T−1AT − λI)T −1x = 0.

Since T is invertible, T[(T−1AT −λI)T−1x] = 0 can only happen if (T−1AT −λI)T−1x = 0. (Recall the relation of the kernel and invertibility in Theorem 20.) This looks almost like (6.3), just a bit more complicated. Let me use some suggestive parentheses to highlight the similarities:

 −1 − 1 [T AT − λI ][T x] = 0.

So, with the selection x′ = T−1x, we have

 −1 ′ ′ T AT x = λx ,

which is what we had to show.

In other words, the eigenvalues of similar matrices are the same. Consequently, we can talk about the eigenvalues of matrices, not just linear transformations. The above theorem implies that the eigenvalues of a transformation and its corresponding matrix are the same. Moreover, the eigenvalues of the matrix don’t depend on the choice of basis.

To be more precise, suppose that A : U →U is a linear transformation and P,Q are bases of U. The matrix of A in some basis S is denoted by AQ. We know that there is a transformation matrix T ∈ℝn×n such that

 −1 AQ = T AP T.

So, the eigenvalues are the same.

All of the above begs the question: how do we actually find eigenvalues? Let’s talk about this next.

day-mode Bookmark

Even though the definition of eigenvalue-eigenvector pairs is easy to understand given the geometric interpretation we just saw, it does not give us any tools to find them in practice. Using them to get simpler representations of matrices is one thing, but we are stuck at square one without a method to find them.

First, let’s focus on the eigenvalues. Suppose that for some λ, there is a nonzero vector x such that Ax = λx. The transformation defined by x →λx is a linear one, and its matrix is diagonal:

 ⌊ λ 0 ... 0⌋ ⌊ x ⌋ | | | 1| || 0 λ ... 0|| || x2|| λx = || .. .. .. ..|| || .. || , ⌈ . . . .⌉ ⌈ . ⌉ 0 0 ... λ xn

where the matrix with λ-s in the diagonal is λI, that is, λ times the identity matrix.

Because linear transformations can be added and subtracted (as we saw in Section 4.1.2), the defining equation Ax = λx is equivalent to

(A − λI)x = 0,

where I denotes the identity transformation, as defined by equation (4.3). In other words, the transformation A−λI maps a nonzero vector to 0, meaning that it is not invertible, as Theorem 20 implies. We can characterize this with determinants: we need to find all λ-s such that

det(A − λI ) = 0.

We can summarize the above findings in the following theorem.

Theorem 37.

Let

be an arbitrary linear transformation. Then

is its eigenvalue if and only if

det(A − λI ) = 0.

Although we are one step closer, finding eigenvalues based on this still seems complicated. In the following, we are going to see what det(A−λI) really is and how we can find the solutions of det(A −λI) = 0 in practice.

Before going into the generalities, let’s revisit the example (6.1). There, we have

 | | | | det(A − λI) = ||2 − λ 1 || || 1 2− λ|| = (2 − λ)2 − 1 = λ2 − 4λ + 3.

To find the eigenvalues, we have to solve the quadratic equation

λ2 − 4λ + 3 = 0,

which we can do easily. Recall that the solutions of any quadratic equation ax2 + bx + c = 0 are

 √ 2------- x1,2 = − b-±--b-−-4ac. 2a

Applying this, we have λ1 = 3 and λ2 = 1 as solutions. There are no other ones, so 1 and 3 are the only two eigenvalues for A.

Let’s see what happens in the general case!

As the example above suggests, if the underlying vector space U is n-dimensional, that is, A is an n ×n matrix, det(A −λI) is an n-th degree polynomial in λ.

To see this, let’s write det(A−λI) explicitly in terms of matrices. With this in mind, we have

 | | |a − λ a ... a | ||11 12 1n || || a21 a22 − λ ... a2n || det(A − λI) = || .. .. .. .. ||. || . . . . || | an1 an2 ... ann − λ |

If you consider the formula to calculate the determinant given by (4.12), you can see that every term is a polynomial. Depending on how many fixed points σ has (that is, points where σ(i) = i), the degree of this polynomial varies between 0 and n.

(Alternatively, you can see that det(A−λI) is a polynomial of degree n by using the recursive formula (4.13) and applying induction.)

Definition 24. (Characteristic polynomial of matrices)

Let A ∈ℝn×n be an arbitrary matrix. The polynomial

p(λ) = det(A − λI)

is called the characteristic polynomial of A.

The roots of the characteristic polynomial are the eigenvalues. If U is an n-dimensional complex vector space (that is, the set of scalars is ℂ), the fundamental theorem of algebra (Theorem 156) guarantees that det(A −λI) = 0 has exactly n roots.

As a consequence, every matrix A ∈ℂn×n has at least one eigenvalue. Note that roots can have higher algebraic multiplicity. For instance, the characteristic polynomial for the matrix

 ⌊ ⌋ | 1 0 0| B = | 0 1 0| ⌈ ⌉ 0 0 2

is (1 −λ)2(2 −λ). So, its roots are 1 (with algebraic multiplicity 2) and 2.

If we restrict ourselves to real matrices and real vector spaces, the existence of eigenvalues and eigenvectors are not guaranteed. For instance, consider

 ⌊ ⌋ 0 − 1 C = ||1 0 ||. ⌈ ⌉

Its characteristic polynomial is λ2 + 1, which doesn’t have any real roots, only complex ones: λ1 = i and λ2 = −i. Mathematically speaking, if we want to stay within the confines of real vector spaces, C has no eigenvalues. However, we are here to do machine learning, not algebra. Thus, we are going to be a bit imprecise and treat real matrices as complex ones. We don’t often need complex numbers to describe mathematical models of a dataset, but they frequently appear during the analysis of matrices.

When an eigenvalue λ is identified, we can set out to find the corresponding eigenvectors; that is, vectors x where (A−λI)x = 0. In more precise terms, we are looking for ker(A −λI).

As we have mentioned before in Section 4.1.4, the kernel of any linear transformation is a subspace. As it might be more than one-dimensional, identifying it often involves an implicit description like x1 + x2 = 0.

Let’s check what happens with our recurring example

 ⌊ ⌋ 2 1 A = ⌈ ⌉ . 1 2

Previously, we have seen that λ1 = 3 and λ2 = 1 are the eigenvalues. To identify the corresponding eigenvectors for, say, λ1, we have to find all solutions for the linear equation (A −λ1I)x = 0. Expanding this, we have

− x1 + x2 = 0 x1 − x2 = 0.

Both equations imply that all x = (x1,x2) are solutions where x1 = x2.

day-mode Bookmark

6.3 Eigenvectors, eigenspaces, and their bases

Section titled “6.3 Eigenvectors, eigenspaces, and their bases”

Definition 25. (Eigenspaces)

Let f : V →V be an arbitrary linear transformation, and λ its eigenvalue. The subspace of eigenvectors defined by

Uλ = {x : Ax = λx}

is called the eigenspace of λ.

Eigenspaces play an important role in understanding the structure of linear transformations. First, we note that a linear transformation keeps its eigenspaces invariant. (That is, if x is in the Uλ eigenspace, then f(x) ∈Uλ as well.) This property makes it possible for us to restrict linear transformations to their eigenspaces.

To illustrate the concept of eigenspaces, let’s revisit the already familiar matrix

 ⌊ ⌋ 2 1 A = ⌈ ⌉ 1 2

one more time. Its eigenvalues are λ1 = 3 and λ2 = 1, and by solving the equation (A −λ1I)x = 0, we get that the eigenspace of λ1 is

U = {x ∈ ℝ2 : x = x }. λ1 1 2

Similarly, you can check that Uλ2 = {x ∈ℝ2 : x1 = −x2}. (If you go back to Figure 6.2, you can visualize Uλ1 and Uλ2.)

Eigenspaces are not necessarily one-dimensional. For instance, consider one of the the previous examples

 ⌊ ⌋ 1 0 0 || || B = ⌈0 1 0⌉ , 0 0 2

with two eigenvalues λ1 = 1 and λ2 = 2. Substituting λ1 back into the equation and solving for (B −I)x = 0 for x, we obtain that

U = {x ∈ ℝ3 : x = 0}, λ1 3

which is simply the plane determined by the first two axes.

The structure of eigenspaces determines whether or not we can diagonalize the matrix A with a change of basis (Section 4.2) transformation Λ = T−1AU. The following general theorem establishes this connection.

Theorem 38. (Diagonalization and eigenspaces)

Let f : V → V be a linear transformation, let A ∈ ℝn×n be its matrix in some basis, and let Uλ1,…,U{λk} be the eigenspaces of f. The following are equivalent.

(a) There is a matrix T ∈ℝn×n such that

 −1 Λ = T AT,

where Λ is a diagonal matrix.

(b) There is a basis u1,…,un for V that can be selected from the eigenvectors of f.

(c) V can be written as the direct sum of the eigenspaces, that is,

V = Uλ1 + ⋅⋅⋅+ Uλk.

(Note that k, the number of eigenspaces, is not necessarily n.)

Proof. (a) ⇒ (b). If

is the matrix of

in some basis, then a similarity transformation is equivalent to a change of basis.

That is, the new matrix Λ = T−1AT is the matrix of f in a different basis, say u1,…,un.

If Λ is diagonal, it can be written in the form

 ⌊ ⌋ |λ1 0 ... 0 | || 0 λ2 ... 0 || Λ = | . . . .| . |⌈ .. .. .. ..|⌉ 0 0 ... λ n

(Note that the λi-s are not necessarily mutually different.) Thus, Λui = λiui, meaning that u1,…,un is a basis from the eigenvectors of f.

(b) ⇒ (a). If u1,…,un is a basis from the eigenvectors of f, then its matrix Λ in that basis is diagonal. Thus, A is similar to Λ, which is what we had to show.

(b) ⇒ (c). By definition, the direct sum (Definition 6) of the eigenspaces contains all linear combinations of the form

 n x = ∑ xu . i i i=1

Since u1,…,un is a basis, V = Uλ1 + ⋅⋅⋅ + Uλk holds.

(c) ⇒ (b). From each eigenspace Uλi, we can select a basis. Due to the construction of Uλi, its basis will consist of eigenvectors.

Since V = Uλ1 + ⋅⋅⋅ + Uλk, the union of of such bases u1,…,un will be a basis for V .

Even though this theorem does not give us any useful recipes on how to diagonalize a matrix, it provides us with an extremely valuable insight: diagonalization is equivalent to finding an eigenvector basis. This is not always possible, but when it is, we are cooking with gas.

In the next chapter, we will take a deep dive into this topic, providing multiple ways to simplify matrices. If our journey in linear algebra is akin to a mountain climb, we will reach the peak soon.

day-mode Bookmark

In this chapter, we’ve veered into the theory side of math once again. This time, it was about eigenvalues and eigenvectors of a matrix, that is, scalars λ and vectors x for which

 n×n Ax = λx, A ∈ ℝ

hold.

Just like most mathematical objects, this might seem daunting at first, but geometrically, this means that in the direction x, the linear transformation A is the same as a stretching by λ. In practice, we can find eigenvectors by solving the so-called characteristic equation

det(A − λI) = 0

for λ.

What are eigenvalues used for? There are tons of applications, but one stands out: according to Theorem 38, if you can build a basis from the eigenvectors of the matrix A ∈ℝn×n, then you can find a T ∈ℝn×n such that T−1AT is diagonal. This process is extremely useful. For one, multiplication with diagonal matrices is fast and simple, and we prefer to do it whenever we can. For another, diagonalization reveals a ton about the internal structure of the underlying linear transformation.

We’ve left this chapter with a multitude of questions. How do we find eigenvalues? What kind of matrices are diagonalizable? If a matrix is diagonalizable, how can we find such a form?

We’ll answer all of these in the next chapter. Be warned: we are approaching the pinnacle of linear algebra. The next chapter might be our heaviest one yet. Just like the final stretch before reaching the peaks of Mount Everest. However, you have my total confidence. If you are here, you can climb it.

Let’s go!

day-mode Bookmark

Problem 1. Compute the eigenvalues of the matrices

 ⌊ ⌋ ⌊ ⌋ | 4 1 − 1| | 2 1 1| A = |⌈ 1 3 1 |⌉ , B = |⌈ 1 2 1|⌉, − 1 1 2 1 1 2

and find an eigenvector for every eigenvalue.

Problem 2. Let A ∈ℝn×n be an upper or lower triangular matrix. Show that the eigenvalues of A are its diagonal elements.

Problem 3. Let A ∈ℝn×n be a square matrix. Show that

det(A − λI )

is a polynomial of degree n in λ.

This is the characteristic polynomial that we have talked about, and we have even mentioned this fact. However, we omitted the proof, so here’s your chance to fill the gap.

Problem 4. Let A ∈ℝn×n, B ∈ℝn×m, and C ∈ℝm×m arbitrary matrices, and we define the so-called block matrix

 ⌊ ⌋ ⌈A B ⌉ (n+m )× (n+m ) D = 0 C ∈ ℝ .

Show that if λ is an eigenvalue of A or an eigenvalue of B, then it’s also an eigenvalue of C.