From the course: Machine Learning Foundations: Linear Algebra
Changing to the eigenbasis
From the course: Machine Learning Foundations: Linear Algebra
Changing to the eigenbasis
- [Instructor] There are many applications in which we have to calculate high powers of square matrix A. What it basically means is that we have to apply the same matrix multiplication many times. We will explore that the most efficient way to calculate A to the power of n, especially for the larger values of n, is to first diagonalize A. Diagonalizing a matrix involves finding its eigenvalues and eigenvectors, and we have to find out how these values are related to those of A to the power of n. Let's Look at a simple example. We have a transformation matrix T that will represent rotation and shift of a vector v. We get the result of applying the transformation T on a vector v by multiplying the T with v, and we get a new vector, and let's call it v1. If we apply the transformation T on the vector v1, we get a new vector v2. We can conclude that this is equal to multiplying the transformation T twice with vector v. So, we can write this down as v2 is equal to T squared multiplied with v. In case when we would like to calculate the position of the final vector vn after n steps, then we could write vn equals T to the power of n times v. Imagine we have to calculate the position of the final vector v after 1,000 steps, or even after 100s of 1,000s steps, these calculations would be troublesome and timely. If there's a way to transform matrix T into diagonal matrix, then this calculation would be easier and straightforward. When we have to multiply a diagonal matrix by itself, all you have to do is multiply the diagonal elements by themselves, meaning you just have to square each diagonal element. In the case when we have to calculate the nth power of a diagonal matrix, we only have to raise each of the elements of the diagonal to the power of n. In order to create an eigenbasis conversion matrix, we have to plug in each of the eigenvectors as columns. There is a theorem that says if n is a positive integer, lambda is an eigenvalue of a matrix, and x is a correspondent eigenvector, then lambda to the power of n is an eigenvalue of T to the power of n, and x is a corresponding eigenvector. Our problem of computing T to the power of n can be simplified to the following. C is our eigenbasis conversion matrix. D is diagonal matrix. So, we can write down our matrix T as T equals matrix C multiplied with diagonal matrix D multiplied with C-inverse. To calculate matrix T squared, we have to multiply C D C-inverse again with itself. In the middle, we have C-inverse multiplied with C, which gives us an identity matrix. We know that when we multiply any matrix with an identity matrix, we get that matrix. Now, we have C multiplied with D again with D, and then with C-inverse. From which, we obtain the relationship T squared equals C multiplied with D squared multiplied with C-inverse. At the end, we can extract our formula for T raised to the power of n. T to the power of n will equal C multiplied with D to the power of n multiplied with C-inverse. And there you have it, you have mastered simple technique changing any basis to the eigenbasis.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.