From the course: Complete Guide to Differential Equations Foundations for Data Science

Linear algebra review

- [Instructor] Before diving into differential equations, I will give you a quick refresher on some key linear algebra concepts. This is because these linear algebra concepts will be used throughout this course with various topics, especially when you explore systems of differential equations. Let's begin by reviewing the foundation of linear algebra matrices. A matrix is a rectangular array of numbers arranged in rows and columns. Matrices are used to represent various systems of equations, including systems of differential equations. Note that the plural form of matrix is matrices. Let's look at some examples of some matrices. So first you have what is called a two by two matrix, since it has two rows and two columns. So this is given by capital A equals and then you have hard brackets, and then it has the numbers inside of it. So first you have the value of one in the top left, four on the top right, seven in the bottom left, and five on the bottom right. So note that when I walk you through a matrix, I will often talk left to right, top to bottom. So for example, I would say this is the matrix A equals one, four, seven, five. That way you know how to follow along later on in the videos. Next, you have a three by three matrix with three rows and three columns, which is given by capital B equals four, three, seven, eight, five, zero, one, two, and five. And finally, you have a two by four matrix, which is given by two rows and four columns, which is given by nine, eight, four, two, two, three, 10, one. Note that for this course you'll mainly be working with matrices that are known as square matrices where they're formatted like matrix capital A and matrix capital B, where they have the same number of rows and columns. There are various matrix operations you can do such as scalar multiplication, addition, subtraction, and regular multiplication. Let's walk through how these work when you're working with matrices. Let's begin with scalar multiplication. So here you have a constant value K multiplied by your matrix capital A. So this is given by the matrix of K multiplied by A11 and you'll notice the way the matrix values are denoted is with two values. So the first value is the row number, so in this case it's the first row, and the second value is the column number it's in. So in this case it's one for the first column. Then you have K multiplied by A12, and then K multiplied by A21, and K multiplied by A22. So it's fairly straightforward for scalar multiplication, you mainly just multiply that scalar for each value in your matrix. Next is addition four two matrices. So this is when you have a matrix capital A and add it with a matrix capital B. Note that you'll generally be doing this with matrices that are the same size. This is given by A11 plus B11 where you are adding in that portion of the matrix where those two values occur in their own matrices. Next, you have A12 plus B12 and then A21 plus B21 and A22 plus B22. So it's fairly straightforward, You essentially just use that operation in the matrix itself where you are just adding where each of those values are in their separate matrices and combining them together. Subtraction works very similarly where if you have capital A minus capital B, this will then equal the matrix of A11 minus B11, A12 minus B12, A21 minus B21, and A22 minus B22. Finally, let's go through multiplication. Note that this is where our themes get a bit trickier, so I'll make sure that I thoroughly explain this. So here you have capital A multiplied by capital B, and this is given by the matrix of A11 multiplied by B11 plus A12 multiplied by B21. So note that the numbers are not all just going to be the values that were in those original spots in their respective matrices that now the numbers are going to get mixed up a little bit. The reason why you then get this arrangement of numbers is due to what is called the dot product of the rows and columns. Looking at the next portion, you have A12 multiplied by B22, plus A11 multiplied by B12, and then you have A21 multiplied by B11 plus A22 multiplied by B21. And finally, you have A22 multiplied by B12 plus A22 multiplied by B22. I'll show you an example of how to do the multiplication, but note that I will make sure I walk you through this, but I will not dive too deep into the theory behind how exactly that works. Let's look at an example using matrix addition. So here you have your matrix capital A equals the matrix of one, two, three, and four. Then you have the matrix capital B, which equals five, six, seven, eight. Using your addition rule, you have capital A plus capital B equals A11 plus B11, A12 plus B12, A21 plus B21, and A22 plus B22. Plugging in your values, You get capital A plus capital B equals one plus five, two plus six, three plus seven, and four plus eight. This gets you capital A plus capital B equals six, eight, 10, and 12. So as you could tell matrix edition is fairly straightforward, you just got to make sure you have all of your values lined up appropriately for where they correspond in the rows and columns of your different matrices. Next up is matrix multiplication. So let's have the matrices, capital A equals one, two, three, four, and then your matrix capital B, which equals two, zero, one, and three. Using your multiplication rule, you have capital A multiplied by capital B equals A11 multiplied by B11 plus A12 multiplied by B21. And then you have A12 multiplied by B22 plus A11 multiplied by B12. Then you have A21 multiplied by B11 plus A22 multiplied by B21. And then A22 multiplied by B12 plus A22 multiplied by B22. Plugging in your values should get capital A multiplied by capital B equals one multiplied by two plus two multiplied by one, one multiplied by zero plus two multiplied by three, three multiplied by two plus four multiplied by one and three multiplied by zero plus four multiplied by three. This gets you a final result of capital A multiplied by capital B equals four, six, 10, and 12. Next step is what is called a determinant. The determinant of a square matrix is a scalar value computed with elements of a matrix. Note that this is used only with square matrices. This determinant provides important information regarding a matrix, such as if it is invertible. For differential equations, a determinant can decide if a system has a unique solution or not. The way you calculate a determinant of a two by two matrix is given by capital A equals A, B, C, and D, and the D determinant of capital A given by the DET. And then in parenthesis you have your matrix, which is capital A is equal to A multiplied by D minus B multiplied by C. So you know this is similar to how you're doing multiplication earlier with your matrix, but your equation is going to be slightly rearranged. Next, if you want to get the determinant of a three by three matrix, you'll get capital B equals A, B, C, D, E, F, G, H, and I. And the determinant of capital B is given by A multiplied by E, multiplied by I minus F, multiplied by H minus B, multiplied by D, multiplied by I minus F, multiplied by G, plus C multiplied by D, multiplied by H minus E, multiplied by G. For this course, you'll mainly be working with the determinants of two by two matrices, but I wanted to show you the three by three matrix formula. That way you know how to use it if you do come across it, and you could tell how quickly it can get more and more complex as you increase the number of dimensions. Let's look at an example of computing the determinant of the matrix Capital A equals three, four, two, and five. Using your determinant formula, you have the determinant of capital A equals A multiplied by D minus B multiplied by C. So note that when you have the DET of A, I will usually just refer to it as the determinant of A. So the determinant of capital A is given by three, multiply by five minus four, multiply by two, which equals 15 minus eight, which gives you a final determinant of capital A equals seven. Now that you know how to find the determinant of a matrix, you can find the inverse of a matrix. To do this, you simply multiply the determinant of the matrix capital A by the adjoint of capital A. So this means you have capital A equals the matrix of A, B, C, and D. And if you want to find the inverse, which is notated by capital A to the negative one, this equals one divided by the determinant of capital A, multiplied by the matrix of D, negative B, negative C, and A. So note that you do get all the values from that original matrix, capital A, this is just the adjoint version of it. Let's look at an example of how to get the inverse of a matrix. So here you have capital A equals three, four, two, and five, and you want to use your formula, capital A to the negative one equals one divided by the determinant of capital A multiplied by the matrix of D, negative B, negative C, and A. Like you computed in the prior example, the determinant of capital A is equal to seven. So this means you have capital A to the negative one equals one divided by seven, multiplied by the matrix of five, negative four, negative two, and three. Once you multiply your fraction through, you'll get capital A to the negative one equals five sevenths, negative four sevenths, negative two sevenths, and three sevenths. Now let's explore eigenvectors and eigenvalues. An eigenvector is a non-zero vector where its direction is unchanged by a given linear transformation. The eigenvalue is the scalar value associated with the eigenvector. Eigenvectors and eigenvalues are given by the equation of capital A multiplied by V equals lambda multiplied by V. So here you have capital A as your matrix, lambda is the eigenvalue, and V is the eigenvector. Eigenvectors and their corresponding eigenvalues are key to solving various systems of differential equations, especially those that are linear and homogenous. If you have a matrix capital A, that is N by N in dimension, you can first find the eigenvalues of capital A by solving the equation of the determinant of capital A minus lambda multiplied by capital I equals zero. So note that you have your eigenvalue lambda here, and then capital I is actually the identity matrix, which is essentially a matrix with all zeros except one diagonal of ones where you have one in the top left and it goes all the way to the bottom right. Next you will then find your corresponding eigenvectors where you have capital A minus lambda multiplied by capital I, and that'll be multiplied by capital X and this will equal zero. Let's look at an example of how to find eigenvalues and their corresponding eigenvectors. So here you have capital A equals three, one, two, and four. Let's use the determinant of capital A minus lambda multiplied by I equal to zero in order to find your eigenvalues. So here your determinant of capital A minus lambda multiplied by capital I equals three minus lambda, one, two, and four minus lambda. Once you multiply this through and subtract it to get your determinant, you'll get three minus lambda multiplied by one minus lambda minus two multiplied by one equals zero. Once you multiply this out, you'll get lambda squared minus seven, multiplied by lambda plus 10 equals zero. Then you can factor this to get Lambda minus five, multiplied by lambda minus two equals zero. The way you then find these eigenvalues is you simply separate them out and move those values to the other side of the equation. So you have lambda one equals five for your first eigenvalue and lambda two equals two for your second eigenvalue. Now let's find the corresponding eigenvectors. So for lambda one equal to five, you'll use the equation capital A minus lambda multiplied by capital I, multiplied by capital X equals zero. So in this case you'll have capital A minus five multiplied by capital I, multiplied by capital X equals zero. So here you have capital A minus five multiplied by capital I, multiplied by the matrix of three minus 5, one, two, and four minus five. This will equal the matrix of negative two, one, two, and negative one. Plugging this in you then get negative two, one, two, and negative one multiplied by what is called a vector since it is just a column of a matrix. Which in this case is X, Y will equal the vector of zero, zero. Multiplying this through gets you negative two, multiplied by X plus Y equals zero. Which if you rearrange, gets you Y equals two multiplied by x. In this case, you can then have the value of X equals to one, which makes Y equal to two, which gets you the first eigenvector of V1 equals one, two. So note that you do have a little bit of flexibility in choosing your eigenvectors, but generally it is easy to go as simple as possible. Next, you have lambda two equals two, where you'll have capital A minus lambda multiplied by capital I. Multiply that by capital X equals zero. Plugging in your lambda gets you capital A minus two, multiplied by capital I, multiplied by capital X equals zero. This gets you capital A minus two, multiplied by capital I, multiplied by three minus two, one, two, and four minus two equal to one, one, two, two. Now you have your matrix one, one, two, two, multiply by the vector X and Y, which should equal the vector zero, zero. Solving this you get X plus Y equals zero for the first one, which means that Y should equal negative X. You can do the same for the second part of this, but it'll say essentially the same thing in the process. So here you can have V2 equals one and negative one since you could have X equals one which makes Y equal to negative one. This means you have the eigenvalues of lambda one equals five and lambda two equals two, where you have your eigenvectors of V1 equals vector one, two, and V2 equals vector one, negative one. I know this is a lot of information to take in and it can be a bit confusing at first. If you're still rusty on your linear algebra skills with the concepts I just reviewed, then I recommend taking some time on your own to further review them. For this course though, I will ensure to guide you through any linear algebra I use. Now that you have had a thorough review of linear algebra, let's begin by jumping into learning all about differential equations in your first chapter.

Contents