1. Home
  2. Explore
  3. Mathematics
  4. Eigenvalue Diagonalization

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Eigenvalue Diagonalization

Transcript

Eigenvalue analysis, eigenvalue decomposition leads to what we call diagonalization. Let's see what that is, and then how that helps us in taking the powers of the matrix, and also of course why we might want to take the powers of any matrix. The first thing to do is to kind of cast the eigenvalue equation in the matrix form. So let's see how we can do that one. As we remember for a square matrix A in ℝⁿˣⁿ, the eigenvectors sᵢ, we're focusing on the real eigenvalues and real eigenvectors.

Now sᵢ is in ℝⁿ, and λᵢ, the eigenvalues, are in ℝ. What that means is that when A works on sᵢ, the eigenvector, it is the same as scaling the eigenvector by the factor λᵢ, the eigenvalue. Now let's arrange the eigenvectors in a matrix as columns. So that is an eigenvector matrix, capital S. And let's create one more matrix, that would be the eigenvalue matrix, arranging the highest eigenvalue in the diagonal position of that matrix. So it's a diagonal matrix

with the eigenvalues along the diagonal. The ordering is important. The iᵗʰ eigenvalue should correspond to the iᵗʰ eigenvector in the first matrix. Now let's compute AS. AS, meaning A applying on this matrix S that is just eigenvectors standing side by side, as you see there. Let's say there are k of them. Ideally we would like k to be the same as n. We would like to have n. But let's say we have only k. k being a number less than or equal to n. Now what does that product AS mean?

Let's use the column picture again for this matrix product. So AS would be a linear combination of the columns of A. What kind of linear combinations? Weighted by the columns in S. What are the columns in S? s₁, s₂, s₃ up to sₖ. So the first column of the product will be a linear combination of the columns of A,  taking the elements in s₁  as the weighting factors. Which is what you see there, As₁. That is a product, and again by column picture, is a linear combination of the columns of A weighted by s₁, the elements of s₁. But we know that As₁ is λ₁s₁, because s₁ is the eigenvector of A with eigenvalue λ₁. Similarly you can get λ₂s₂, etc. So you get a matrix which are basically scaled versions of the columns of S, but scaled by different eigenvalues, the eigenvalues. Let's just compute another matrix, SΛ. Remember Λ is the iᵗʰ eigenvalue along the diagonal and nothing else. Everything else is zero.

Again, let's use the column picture. The product will contain columns that are linear combinations of these columns in the matrix S, s₁, s₂, up to sₖ. What kind of linear combinations? Scaled by the columns in Λ, the capital Λ. But the first column of Λ is just λ₁ in position (1,1), everything else is zero. So that is just λ₁s₁. The second column in Λ is zero, and then λ₂ in position (2,2), and that scales s₂. So as you can see that gives you

λ₁s₁, λ₂s₂, up to λₖsₖ as vectors standing side by side. So as you can see that these two products are the same. So this is just the definition of the eigenvalue equation, just casting it in matrix form. So we can say that AS is the same as SΛ. Remember Λ is the iᵗʰ eigenvalue along the diagonal. Like I said in the beginning, we would like to have n of them. But this equation AS = SΛ is valid even if you don't have n eigenvectors.

Because this is basically just the definition of the eigenvalue equation that you see right there, just in the matrix form. So the golden nugget here is AS = SΛ. Let's go one step further and say that we do have n eigenvectors, and on top of that they're linearly independent. If that is the case, then this matrix S is a non-singular matrix. What's always true is AS = SΛ because that is just the definition. That is just the eigenvalue equation. But if S is non-singular, if it is invertible,

that means if you have n linearly independent eigenvectors, then you can multiply that equation on the right by S⁻¹, because S⁻¹ is there. And then you get A = SΛS⁻¹. That is an eigenvalue decomposition of A. A is now factorized into three matrices. The middle one is a diagonal matrix Λ, the eigenvalue matrix, the same size as A but a diagonal matrix, and that is diagonalization. So eigenvalue decomposition, also known as diagonalization, and this is it. So diagonalization is a process

of writing a matrix as a  product of three matrices, the middle one of which is actually diagonal. Now let's see why we want to do this. One reason is that if you have diagonalization, you can compute the powers of the matrices much faster computationally, much more efficiently. Let's take a look at why. If you can write A as SΛS⁻¹, A² of course is A × A, which is SΛS⁻¹ × SΛS⁻¹. And S⁻¹ × S is I, inverses multiplying giving you I. Then you get SΛ²S⁻¹. And you can keep going to get that green equation there. Aᵏ is SΛᵏS⁻¹.

And this is important. This is interesting because if you wanted to compute Aᵏ... as you know the best algorithm we have for matrix multiplication is of the order n²·³. And you have to do that k times. So it's k × n²·³ operations. That's what you would need.  But with diagonalization,  what is it that you have? You have SΛᵏS⁻¹. So Λᵏ is actually very easy to do. Because Λ is a diagonal matrix, to the power k would be just taking the power k of the diagonal elements. That is just n operations. n exponentiations. We'll call that n operations. And then there are two matrix multiplications.

So the situation looks like it's n + 2n²·³. So that is much smaller than k × n²·³, especially when k is large. So the saving, if you do the algebra there, you get k/2 when you take the  limit n tends to infinity.  So if n is like 100 or so, which is a fairly modest matrix, then it is sufficiently close to infinity. And if the kᵗʰ power that you want to take is say 100ᵗʰ power, which you might have to do, then the saving is of the order of 50, which is significant. Now another important thing to realize is that even though we took products of matrices, it actually works when you take the inverse also. So let's compute A⁻¹. A⁻¹ is of course (SΛS⁻¹)⁻¹. And using the product rule of inverses, inverses will come in the opposite order. So it's (S⁻¹)⁻¹ × Λ⁻¹ × S⁻¹.

Again that is SΛ⁻¹S⁻¹. That is beautiful, because even though you're taking inverses, it looks like you're taking the powers. So S⁻¹... or Λ⁻¹ is the inverse of a diagonal matrix, which is another diagonal matrix with each diagonal element being the reciprocal of the original element. So you can actually write A⁻ᵏ, which means A⁻¹ multiplying k times, but you can write it as A⁻ᵏ without any ambiguity.  And that is nice because  mathematically consistent, and also it leads to some interesting expansions that you can define. We will see that in the next slide. So why would you want to take powers? It's a common technique in mathematical modeling is to say that the system that you're studying is described by one vector, a state vector. It's got a number of parameters that you measure, those form the elements of a vector. Then in each time step,

or in each iterative step, the system transitions to the next one through the application of a matrix. That is how you would model it in mathematics. And that is called a difference equation, and also it's called a Markov chain. Where the current state depends only on the previous state, and that dependence is encoded in a matrix. So if you have the original state x₀, you can find x₁ through the application of a matrix. There's another thing that you can do, which is the exponential of a matrix.

It's kind of weird. You know what eˣ is, and there's a Taylor series expansion of that. Since the Taylor series expansion contains x¹, x², x³, up to infinity really, and we know how to take A¹, A², A³, up to infinity using diagonalization. You can actually write formally eᴬ using the same series, and it actually works.  And this is used in solving  differential equations, and that is a topic that you might see in some videos. It's not part of this course. So we won't delve on this anymore. But it is possible to use Taylor series expansion in conjunction with diagonalization and the facility that we have in taking powers of the matrices to write the exponent of a matrix, or rather e to the power of a matrix. So let's take a look at this difference equation

once more. A first-order difference equation means it depends only on the previous stage. So let's say you want the kᵗʰ iterative step. The kᵗʰ state of the system depends on the state of the system at the previous iterative step, which was k - 1, through the application of a matrix A. Given that, you can write that x₁ is Ax₀. x is some kind of state vector with some measurements in it. Then x₂ becomes Ax₁. But we know what x₁ is, it is Ax₀.

So x₂ becomes A²x₀. And going like that, you can see that the kᵗʰ state is Aᵏx₀. This becomes easy to compute once you have diagonalization. Without diagonalization, this becomes an expensive thing to do computationally. Similarly, you can think of second-order difference equations where the current state depends on not merely the previous state, but the state before that also. So those are different examples that we can think of, and we will illustrate it using a kind of an academic  example coming up soon. But before doing that, let's take a look at basis. Again, if you have n linearly independent eigenvectors for the matrix A in ℝⁿˣⁿ. Any vector x₀ in ℝⁿ can be expressed as a linear combination of these eigenvectors because you have enough of them. They're linearly independent, so they form a basis. So x₀ is c₁s₁ + c₂s₂ and so on up to cₙsₙ. And if you look at that, that is

a linear combination of the eigenvectors. If you put them in a matrix S, and c that you see there is the component of the vector x₀ expressed in the eigenbasis. So those are the coordinates in the eigenbasis. Why is that interesting? Let's take a look. If you want to compute x₁, you're just multiplying x₀ with A. And you can just multiply our linear combination, Σ(cᵢsᵢ), with A. And then A goes inside and commutes with cᵢsᵢ. Then you get cᵢλᵢsᵢ because A applying on sᵢ, the eigenvector, just spits out the eigenvalue λᵢ. So you get that expression there, which is neat. Now x₂ is A applying on x₁. So that just becomes λᵢ² inside the summation. Similarly xₖ becomes cᵢλᵢᵏsᵢ,

sum with the index running from 1 to n. That is what I have written there in longhand. But of course you have a more compact form of that in the world of matrices. So xₖ is Aᵏx₀, and x₀ is Sc, where c is the vector x₀ expressed in the eigenbasis. Then you can see that xₖ is SΛᵏc. There's nothing different here. It's just looking at the same thing that we saw in the difference equation in the previous slide here, but using the eigenbasis. Now let's take one example. This is a kind of an interesting example because it's very close to nature. You must have heard of the Fibonacci sequence. That is a sequence that starts with 0, 1, and the next number is a sum of the previous two. So 0, 1. The third number is 0 + 1. Fourth number is 1 + 1. Fifth number is 1 + 2 and so on.

And so as you can see, it grows very fast. And this appears in nature all over the place for reasons that are barely understood. It might be interesting to see what we can say about these numbers using our understanding of eigenvalues and eigenvectors. If you just look at it now, there isn't even a matrix there. So where the heck will eigenvalues or eigenvectors come from? We can cast it in a matrix form. That's what we will see. As of now, this is kind of like a second-order difference equation, where the k+2 Fibonacci number depends on the k+1 and kth Fibonacci numbers. It's just a sum of those two. Now, if you want to understand these numbers and answer questions like, how fast are these numbers growing, and can you kind of get a  closed form approximation  for the kth Fibonacci number? Those look like insurmountable problems now, but they can be surmounted.

We will see how that is done. What we will do is to create a first-order matrix equation, a difference equation, by creating a vector. The kth vector by putting two Fibonacci numbers in a vector, the k+1 and the kth one. That means if you want to get the k+1 vector, that would be the k+2 number and k+1 Fibonacci number. And then you can write, with a little bit of understanding of what Fibonacci numbers are... the k+2 Fibonacci number, of course, is the k+1 plus the kth one.

And if you look at it,  there's a matrix hiding there.  You can see that Fₖ₊₂ is Fₖ₊₁ + Fₖ. And that comes from the matrix multiplication in the top row. And Fₖ₊₁ is just Fₖ₊₁. That comes from the matrix multiplication in the second row. So that is a matrix equation. Now we have found a matrix. Once you have a matrix, you can do eigenanalysis. It's a square matrix. Let's look at that. What's important to understand is that xₖ₊₁ now is A × xₖ,

and everything that we said about the difference equation applies now. So A is that matrix. You can write down the characteristic polynomial and the characteristic equation there by (A - Iλ) and then taking the determinant. And you get a quadratic equation. And the quadratic equation happens to be one of the most famous quadratic equations in the world. First of all, let's look  at that quadratic equation  to the difference equation. Moving everything in that difference equation to one side, you get that  green difference equation, the second-order difference equation for Fibonacci numbers. And comparing that to the characteristic equation,  you can see that there is  some kind of correspondence between the properties of the eigenvalues and how the second-order difference equation is evolving. That's not an accident. That is all the beautiful consistency of linear algebra and mathematics in general. Now we know the sum and product of eigenvalues from the properties.

λ₁ + λ₂, the two eigenvalues, will be the trace of the matrix A, that is just 1. And λ₁ × λ₂ is -1. And with that you can compute them, or you can just use the roots of the quadratic equation. And then you get (1 ± √5)/2. Do you recognize that number? (1 + √5)/2 is the golden ratio. The golden ratio has an uncanny significance in our aesthetic sense. In architecture, the best-looking rectangle... the best-looking people, actors, their ratios of noses to eyes or whatever...

All those things turn out to be very close to the golden ratio. Those proportions are the most pleasing ones to us human beings. Again, almost eerily uncanny, all these things. So λ₁ is 1.618, that is the golden ratio. And λ₂ is -0.618. The largest λ,   its absolute value being greater than 1, indicates a growth in the difference equation. That is an indication that the Fibonacci numbers will be growing. Now that also tells you how fast

the Fibonacci sequence is growing. It is proportional to λ, the dominant eigenvalue. The largest eigenvalue by absolute value to the power k. It grows like that. How does that come about? That is because you can write x₀ as a linear combination of the eigenvectors. And then xₖ is Aᵏ applying on x₀. Using our eigenbasis, we can see that xₖ is c₁λ₁ᵏs₁ + c₂λ₂ᵏs₂, which is the same as SΛᵏc in the world of matrices, in the matrix form. And if you take k tending to infinity, λ₂ being less than 1, λ₂ᵏ will tend to zero. So that will just go away. Then xₖ will be roughly the same as c₁, whatever that component is for x₀ in the eigenbasis, c₁λ₁ᵏs₁. And so it is growing like λ₁ᵏ.

Now let's go ahead and complete this analysis to say that we actually want to compute c₁. So in order to do that, we have to compute s₁ and s₂, which is very easy. It'll turn out that s₁ is [λ₁, 1]ᵀ, and s₂ is [λ₂, 1]ᵀ. And xₖ, the kth state vector, which is comprised of the k+1 Fibonacci number and the kth Fibonacci number, that looks like c₁λ₁ᵏs₁ + ... Wait, you can expand it out. Then you can see that the k+1 Fibonacci number is c₁λ₁ᵏ⁺¹, and the kth Fibonacci number, as we expect, is c₁λ₁ᵏ. Fₖ is roughly c₁λ₁ᵏ,

and we just need to find out what c₁ is. In order to do that, we'll just look at x₀. That is [F₁, F₀]ᵀ. F₁, as you know   starting from the Fibonacci sequence, F₁ is 1, F₀ is zero. And then do this little bit of equation solving, kindergarten-level simultaneous equations. At this point in our linear algebra life, we'll get a system of two equations: c₁λ₁ + c₂λ₂ adding up to 1. c₁ and c₂ adding up to zero. And from that we'll get c₁ = 1/√5,

by plugging in the values for λ₁ and λ₂. And then you can say that Fₖ, the kth Fibonacci number, is (1/√5) times the golden ratio to the power k. That is a closed form formula for the kth Fibonacci number. And let's see how good that is. The table is there in the book, and also there is a visualization that we can take a quick look at on the website of the book. Go down to Fibonacci. This is a simulation. So the first Fibonacci number 1,

and the second Fibonacci number 1. Remember, the zero Fibonacci number was 0. So the true sequence Fₖ, the kth Fibonacci number, k being 1. Now that was 1, but the eigenvalue approximation for that is 1.17. So there is some error there. So you can see that represented there on the right-hand side. And if you go to the next one, the Fibonacci number turns out to be 2, but the approximation is 1.89. The next one, next one... by the time you reach the fifth one, the error is surprisingly small.

The true number is 8. The approximation is 8.02. By the time you reach the 10th Fibonacci number, the error is basically invisible. You cannot really see any difference between the two. And if you go up to say 14 or 15, and the error is a few parts in a billion or so, or maybe even smaller than that. So it's a very, very good approximation coming out of an eigenvalue analysis of a matrix that we kind of cooked up, based on the fact that a second-order difference equation can be cast as a first-order difference equation in the matrix form, and we went ahead and did an analysis on that one. So that was kind of like an academic exercise that you could look at and see that these things work surprisingly well. But there are other applications for data science and computer science. Probably the most impressive one is called Principal Component Analysis. That is an eigenvalue decomposition of the covariance matrix.

And some of you would have already used it in your project. And in any case, this will come toward the end of our course in the last chapter, as a part of singular value decomposition. But it really is an eigenvalue decomposition of the covariance matrix of the data set. And slightly farther afield from our neck of the woods, quantum mechanics is built on linear algebra. Schrödinger's equation really is an eigenvalue equation. These things are not critical for computer science per se,

but it is something that we use every single day. Can you guess where? Your iPhone and all the electronic gadgets these days? They're all built based on quantum mechanical equations. Starting from the energy states of a hydrogen atom, they are the eigenvalues of an energy operator called the Hamiltonian. And the reason why semiconductors work the way they do is because they have energy levels and energy gaps coming out of the fact that only certain discrete quantized energy levels are allowed.

And they are the eigenvalues of this Hamiltonian. You see, so these things are critical for our technology in today's world. Then Markov matrices and steady states. That is a technique that the PageRank algorithm was built on. That also is an eigenvalue analysis on a particular state transition matrix, which is a stochastic matrix.  Again, this is something  that is coming up next week. So take a look at that one. See how it worked for population and migration analysis. Very interesting.

The same idea is used in the PageRank algorithm, whereby it is similar to a fancy country where people end up, and that is like a very popular website also. Then a Hidden Markov chain is used... another Markov difference equation kind of idea... in part of speech tagging in natural language processing. So all these things are actually quite relevant. Natural language processing has lost its glamour a little bit to large language models. But even in large language models, the basic idea comes from linear algebra. That brings us to the end of chapter 11. For my students at SMU, this is the last chapter that you will be tested on. Eigenvalue decomposition is included in your final exam. But everything that comes after this, chapters 12 and 13, will not be tested in your final exam. And since you guys are probably quite busy with a lot of other projects and modules. It is likely that you may not even get to watch

those videos that I have created before, and I may not create new ones for those chapters. Let's see. It depends on your interest in the course at this point. In any case, some of you who have used SVD for your project work may be interested in those chapters as well. Next video, be it the old one that I created a few years ago or the new ones that I might create, will be on things like Markov matrices and quadratic forms and Jordan canonical form. Another kind of canonical form

coming from the same cool cat Jordan. Those things might be abstract and mathematical, but take it as a challenge. We learn these things not because ChatGPT and Gemini don't know these things. It's because we find these things intellectually stimulating and satisfying. At least I do. And that's the reason why I spend time on these things. And I invite you to do the same. And it adds value and richness to your lives.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent