1 00:00:02,632 --> 00:00:04,090 GILBERT STRANG: This is a good time 2 00:00:04,090 --> 00:00:08,670 to do two by two matrices, their eigenvalues, 3 00:00:08,670 --> 00:00:09,715 and their stability. 4 00:00:12,360 --> 00:00:16,470 Two by two eigenvalues are the easiest 5 00:00:16,470 --> 00:00:19,390 to do, easiest to understand. 6 00:00:19,390 --> 00:00:23,930 Good to separate out the two by two case from the later n 7 00:00:23,930 --> 00:00:25,980 by n eigenvalue problem. 8 00:00:28,610 --> 00:00:37,070 And of course, let me remember the basic dogma of eigenvalues 9 00:00:37,070 --> 00:00:38,360 and eigenvectors. 10 00:00:38,360 --> 00:00:43,440 We're looking for a vector, x, and a number, lambda, 11 00:00:43,440 --> 00:00:47,840 the eigenvalue, so that Ax is lambda x. 12 00:00:47,840 --> 00:00:52,490 In other words, when I multiply by A, 13 00:00:52,490 --> 00:00:56,820 that special vector x does not change direction. 14 00:00:56,820 --> 00:01:01,540 It just changes length by a factor lambda, 15 00:01:01,540 --> 00:01:03,290 which could be positive. 16 00:01:03,290 --> 00:01:05,040 It could be zero. 17 00:01:05,040 --> 00:01:06,500 Could be negative. 18 00:01:06,500 --> 00:01:08,240 Could be complex number. 19 00:01:08,240 --> 00:01:09,820 It's a number, though. 20 00:01:09,820 --> 00:01:15,150 So that's the key equation. 21 00:01:15,150 --> 00:01:17,990 Let me go toward its solution. 22 00:01:17,990 --> 00:01:22,670 So I want to move that onto the left hand side. 23 00:01:22,670 --> 00:01:26,230 So I just write the same equation this way. 24 00:01:26,230 --> 00:01:33,160 And now I see that this matrix times the vector gives me 0. 25 00:01:33,160 --> 00:01:36,580 Now, when is that possible? 26 00:01:36,580 --> 00:01:39,780 That matrix can't be invertible. 27 00:01:39,780 --> 00:01:44,000 If it was invertible, the only solution would be x equals 0. 28 00:01:44,000 --> 00:01:45,340 No good. 29 00:01:45,340 --> 00:01:50,370 So this matrix must be singular. 30 00:01:50,370 --> 00:01:52,370 It's determined it must be 0. 31 00:01:52,370 --> 00:01:56,740 And now we have an equation for the eigenvalue lambda. 32 00:01:56,740 --> 00:02:00,830 So lambda is how much we shift the matrix 33 00:02:00,830 --> 00:02:03,380 to make the determinant 0. 34 00:02:03,380 --> 00:02:07,220 We shift by lambda times the identity 35 00:02:07,220 --> 00:02:10,789 to subtract that from the diagonal. 36 00:02:10,789 --> 00:02:15,950 So can I begin with very easy two by two matrix, 37 00:02:15,950 --> 00:02:21,450 the kind that we met first, called a companion matrix. 38 00:02:21,450 --> 00:02:27,980 So we met this matrix when we had a second order equation. 39 00:02:27,980 --> 00:02:34,790 So I started with the equation y double prime plus By prime plus 40 00:02:34,790 --> 00:02:38,750 Cy equals, say, 0. 41 00:02:38,750 --> 00:02:43,150 So I started with one second order equation. 42 00:02:43,150 --> 00:02:48,310 And then I introduced y prime as a second unknown. 43 00:02:48,310 --> 00:02:52,250 So now I have a vector unknown, y and y prime. 44 00:02:52,250 --> 00:02:56,610 And then, when I wrote the equation down-- 45 00:02:56,610 --> 00:03:01,930 I won't repeat that-- it led us to a two by two matrix. 46 00:03:01,930 --> 00:03:05,910 Two equations for two unknowns, y and y prime. 47 00:03:05,910 --> 00:03:10,410 So there is a two by two matrix that we're interested in. 48 00:03:10,410 --> 00:03:14,880 But we really are going to be interested in all two by twos. 49 00:03:14,880 --> 00:03:20,330 So let me take that to be my matrix A, my companion matrix. 50 00:03:20,330 --> 00:03:23,290 So I just want to go through the steps 51 00:03:23,290 --> 00:03:25,550 of finding its eigenvalues. 52 00:03:25,550 --> 00:03:29,760 What are the eigenvalues of that matrix? 53 00:03:29,760 --> 00:03:33,940 We just take the matrix, subtract lambda 54 00:03:33,940 --> 00:03:39,490 from the diagonal, and take the determinant. 55 00:03:39,490 --> 00:03:43,140 And when I take the determinant of a two by two matrix, 56 00:03:43,140 --> 00:03:46,200 it's just that times that, which is 57 00:03:46,200 --> 00:03:49,940 minus lambda times minus lambda is lambda squared. 58 00:03:49,940 --> 00:03:52,300 This gives me a B lambda. 59 00:03:52,300 --> 00:03:55,180 And the other part of the determinant 60 00:03:55,180 --> 00:03:59,380 is this product, minus C. But it comes with a minus sign, 61 00:03:59,380 --> 00:04:04,920 so it's plus C. So there's my equation for the eigenvalues 62 00:04:04,920 --> 00:04:09,490 of a companion matrix. 63 00:04:09,490 --> 00:04:14,340 And of course you see that's exactly the same equation 64 00:04:14,340 --> 00:04:18,750 that we had for the exponent s. 65 00:04:18,750 --> 00:04:28,680 So lambda for the matrix case is the same as s, s1 and s2 66 00:04:28,680 --> 00:04:35,300 for the single second order equation. 67 00:04:35,300 --> 00:04:39,760 So this equation has solutions e to the st 68 00:04:39,760 --> 00:04:46,010 when the matrix has the eigenvalues lambda equal s. 69 00:04:46,010 --> 00:04:49,870 Those same s1 and s2. 70 00:04:49,870 --> 00:04:57,260 But now I move on to a general two by two matrix. 71 00:04:57,260 --> 00:04:59,630 What are its eigenvalues? 72 00:04:59,630 --> 00:05:03,470 What does that equation looks like for its two eigenvalues? 73 00:05:03,470 --> 00:05:07,280 So this will be a special case of this. 74 00:05:07,280 --> 00:05:12,070 Here, I have a general matrix, a, b, c, d. 75 00:05:12,070 --> 00:05:14,880 I've subtracted lambda from the diagonal. 76 00:05:14,880 --> 00:05:16,750 I'm taking the determinant. 77 00:05:16,750 --> 00:05:19,950 That'll give me the two eigenvalues. 78 00:05:19,950 --> 00:05:22,170 Let's do it. 79 00:05:22,170 --> 00:05:26,140 Minus lambda times minus lambda is lambda squared. 80 00:05:26,140 --> 00:05:30,190 Then I have a minus lambda d and a minus lambda a. 81 00:05:30,190 --> 00:05:34,900 So I have an a plus a d lambda. 82 00:05:34,900 --> 00:05:37,880 And then I have the part that doesn't involve lambda. 83 00:05:37,880 --> 00:05:40,530 The part that doesn't involve lambda 84 00:05:40,530 --> 00:05:44,450 is just the determinant of a, b, c, d. 85 00:05:44,450 --> 00:05:47,660 It's just the ad and the minus bc. 86 00:05:47,660 --> 00:05:53,160 So there's an ad and a minus bc, and all that is 0. 87 00:05:56,700 --> 00:05:59,600 It's a quadratic equation, second degree. 88 00:05:59,600 --> 00:06:02,750 A two by two matrix has two eigenvalues, 89 00:06:02,750 --> 00:06:05,990 the two roots of that equation. 90 00:06:05,990 --> 00:06:10,120 I just want to understand more and more and more 91 00:06:10,120 --> 00:06:13,410 about the connection of the roots, lambda 1 lambda 92 00:06:13,410 --> 00:06:17,640 2, to the matrix a, b, c, d. 93 00:06:17,640 --> 00:06:22,610 If I know the two by two matrix, this tells me the eigenvalues. 94 00:06:22,610 --> 00:06:28,710 So this will, being a quadratic equation, have two roots. 95 00:06:31,510 --> 00:06:36,290 So if I factor this, this will factor into lambda minus lambda 96 00:06:36,290 --> 00:06:40,980 1 times lambda minus lambda 2. 97 00:06:40,980 --> 00:06:43,710 And of course, if the numbers are nice, 98 00:06:43,710 --> 00:06:48,270 then I can see what lambda 1 and lambda 2 are. 99 00:06:48,270 --> 00:06:53,080 In that case, I find the eigenvalues. 100 00:06:53,080 --> 00:06:57,210 If the numbers are not nice, then lambda 1 and lambda 2 101 00:06:57,210 --> 00:07:01,460 come from the quadratic formula, the minus b plus or minus 102 00:07:01,460 --> 00:07:05,350 square root of b squared minus 4ac. 103 00:07:05,350 --> 00:07:09,590 The quadratic formula will solve this equation, will tell me 104 00:07:09,590 --> 00:07:11,130 these two numbers. 105 00:07:11,130 --> 00:07:17,420 And if I multiply it out this way, I see lambda squared. 106 00:07:17,420 --> 00:07:24,450 I see minus lambda times lambda 1 and lambda 2. 107 00:07:27,180 --> 00:07:34,710 And then I see plus lambda 1 times lambda 2 equals 0. 108 00:07:37,270 --> 00:07:41,360 Here, I've written the equation for the two lambdas. 109 00:07:41,360 --> 00:07:45,740 Here, I've written the equation when I know the two lambdas. 110 00:07:45,740 --> 00:07:47,200 Why did I do this? 111 00:07:47,200 --> 00:07:50,710 I want to match this with this and see 112 00:07:50,710 --> 00:07:57,720 that this number, whatever it is, is the same as that number. 113 00:07:57,720 --> 00:08:01,130 They show up there, the coefficient of minus lambda. 114 00:08:01,130 --> 00:08:09,380 So that's the first step, that lambda 1 plus lambda 2 115 00:08:09,380 --> 00:08:12,020 is the same as a plus d. 116 00:08:15,400 --> 00:08:18,890 Just matching those two equations. 117 00:08:18,890 --> 00:08:23,890 This is just like a general fact about a quadratic equation. 118 00:08:23,890 --> 00:08:30,370 The sum of the roots is the minus coefficient of lambda. 119 00:08:30,370 --> 00:08:35,679 And then the constant term is the constant term. 120 00:08:35,679 --> 00:08:42,183 So lambda 1 times lambda 2 is ad minus bc. 121 00:08:46,880 --> 00:08:53,850 These are facts about a two by two matrix, a, b, c, d. 122 00:08:53,850 --> 00:08:55,650 The sum of the eigenvalues. 123 00:08:55,650 --> 00:08:57,670 So this is the sum of the eigenvalues-- 124 00:08:57,670 --> 00:09:01,790 so I'll put s-u-m to indicate that I'm looking 125 00:09:01,790 --> 00:09:06,470 at the sum-- is that a plus d. 126 00:09:06,470 --> 00:09:09,420 A plus d are the numbers on the diagonal. 127 00:09:09,420 --> 00:09:11,350 So that's a little special. 128 00:09:11,350 --> 00:09:13,950 When I add the diagonal numbers, I 129 00:09:13,950 --> 00:09:19,590 get something called the trace of the matrix. 130 00:09:23,210 --> 00:09:25,580 I'm introducing a word, trace. 131 00:09:25,580 --> 00:09:28,750 Trace is the add up down the diagonal. 132 00:09:28,750 --> 00:09:30,240 And that matches a plus d. 133 00:09:30,740 --> 00:09:38,460 And this one is the product of the eigenvalues lambda 134 00:09:38,460 --> 00:09:40,180 1 times lambda 2. 135 00:09:40,180 --> 00:09:41,650 So that's the product. 136 00:09:41,650 --> 00:09:46,110 And that's equal to the determinant of a. 137 00:09:49,490 --> 00:09:53,890 I'm just making all the neat connections that 138 00:09:53,890 --> 00:09:57,700 are special for a two by two. 139 00:09:57,700 --> 00:10:00,920 So that if I write down some matrices, 140 00:10:00,920 --> 00:10:02,780 we could look at them immediately. 141 00:10:02,780 --> 00:10:05,920 Let me write down a matrix. 142 00:10:05,920 --> 00:10:07,630 Suppose I write down that matrix. 143 00:10:14,140 --> 00:10:25,320 Oh, let me make them 0, 1-- well, 0, 4-- ah, 144 00:10:25,320 --> 00:10:27,170 let me improve this a little. 145 00:10:27,170 --> 00:10:30,481 2, 4, 4, 9. 146 00:10:30,481 --> 00:10:32,351 2, 4, 4, 2 would be even easier. 147 00:10:32,351 --> 00:10:32,850 Sorry. 148 00:10:36,420 --> 00:10:38,810 I look at that matrix. 149 00:10:38,810 --> 00:10:42,730 I see immediately the two eigenvalues of that matrix 150 00:10:42,730 --> 00:10:44,646 add to 4. 151 00:10:44,646 --> 00:10:46,200 2 plus 2 is 4. 152 00:10:46,200 --> 00:10:48,400 I took the trace. 153 00:10:48,400 --> 00:10:51,440 The two eigenvalues of that matrix multiply 154 00:10:51,440 --> 00:10:58,110 to the determinant, which is 2 times 2 is 4 minus 16 minus 12. 155 00:10:58,110 --> 00:11:03,350 So the sum here for that matrix would be 4. 156 00:11:03,350 --> 00:11:06,860 The determinant of that matrix would be 4 minus 16 157 00:11:06,860 --> 00:11:08,760 is minus 12. 158 00:11:08,760 --> 00:11:15,980 And maybe I can come up with the two numbers that have add to 4 159 00:11:15,980 --> 00:11:17,750 and multiply to minus 12. 160 00:11:17,750 --> 00:11:22,285 I think, actually, that they are six and minus 2. 161 00:11:22,285 --> 00:11:28,370 I think that the eigenvalues here are 6 and minus 2 162 00:11:28,370 --> 00:11:31,500 because those add up to 4, the trace, 163 00:11:31,500 --> 00:11:35,630 and they multiply 6 times minus 2 is minus 12. 164 00:11:35,630 --> 00:11:38,550 That's the determinant. 165 00:11:38,550 --> 00:11:41,790 Two by two matrices, you have a good chance 166 00:11:41,790 --> 00:11:44,590 at seeing exactly what happens. 167 00:11:44,590 --> 00:11:53,630 Now, my interest today for this video is to use all this, 168 00:11:53,630 --> 00:11:58,220 use the eigenvalues, to decide stability. 169 00:11:58,220 --> 00:12:02,540 Stability means that the differential equation 170 00:12:02,540 --> 00:12:05,700 has solutions that go to 0. 171 00:12:05,700 --> 00:12:11,110 And we remember the solutions are 172 00:12:11,110 --> 00:12:16,330 e to the st, which is the same as e to the lambda t. 173 00:12:16,330 --> 00:12:20,520 The s and the lambda both come from that same equation 174 00:12:20,520 --> 00:12:27,770 in the case of a second order equation reduced to a companion 175 00:12:27,770 --> 00:12:28,890 matrix. 176 00:12:28,890 --> 00:12:37,560 So I'm interested in when are the eigenvalues negative. 177 00:12:37,560 --> 00:12:39,740 When are the eigenvalues negative? 178 00:12:39,740 --> 00:12:42,500 Or if they're complex numbers, when 179 00:12:42,500 --> 00:12:44,720 are their real parts negative. 180 00:12:44,720 --> 00:12:51,400 So can we remember trace, the sum, product, the determinant. 181 00:12:51,400 --> 00:12:54,820 And answer the stability questions. 182 00:12:54,820 --> 00:12:55,995 So I'm ready for stability. 183 00:12:59,620 --> 00:13:04,090 So stability means either lambda 1 negative 184 00:13:04,090 --> 00:13:07,710 and lambda 2 negative. 185 00:13:07,710 --> 00:13:09,145 This is in the real case. 186 00:13:11,840 --> 00:13:21,270 Or in the complex case, lambda equals some real part 187 00:13:21,270 --> 00:13:25,690 plus and minus some imaginary part. 188 00:13:25,690 --> 00:13:29,190 Then we want the real part to be negative. 189 00:13:29,190 --> 00:13:34,490 Real part of a lambda, which is a, should be 0. 190 00:13:34,490 --> 00:13:36,460 So that's our requirement. 191 00:13:36,460 --> 00:13:38,750 If the eigenvalues are complex, we 192 00:13:38,750 --> 00:13:42,010 get a pair of them and the real part 193 00:13:42,010 --> 00:13:46,990 should be 0 so that e to the-- the point about this negative a 194 00:13:46,990 --> 00:13:52,020 is that e to the at will go to 0. 195 00:13:52,020 --> 00:13:53,910 The point about these negative lambdas 196 00:13:53,910 --> 00:13:58,650 is that e to the lambda t will go to 0. 197 00:13:58,650 --> 00:14:01,630 This is stability. 198 00:14:01,630 --> 00:14:11,030 So my question is, what's the test on the matrix that decides 199 00:14:11,030 --> 00:14:13,360 this about the eigenvalues? 200 00:14:15,980 --> 00:14:18,340 Can we look at the matrix-- maybe 201 00:14:18,340 --> 00:14:21,580 we don't have to find those eigenvalues. 202 00:14:21,580 --> 00:14:23,330 Maybe we can use the fact. 203 00:14:23,330 --> 00:14:27,340 Again, the fact is that lambda 1 plus lambda 2 204 00:14:27,340 --> 00:14:36,790 is the trace and lambda 1 times lambda 2 is the determinant. 205 00:14:36,790 --> 00:14:40,580 And we can read those numbers off from the matrix. 206 00:14:40,580 --> 00:14:42,950 Then there's a quadratic equation. 207 00:14:42,950 --> 00:14:47,690 But if we only want to know information like 208 00:14:47,690 --> 00:14:50,560 are the eigenvalues negative? 209 00:14:50,560 --> 00:14:53,360 Are their real parts negative? 210 00:14:53,360 --> 00:14:57,490 We can get that information from these numbers 211 00:14:57,490 --> 00:15:03,110 without going to finding the eigenvalues 212 00:15:03,110 --> 00:15:05,110 from that quadratic equation. 213 00:15:05,110 --> 00:15:08,740 Wouldn't be that hard to do, but we don't have to do it. 214 00:15:08,740 --> 00:15:13,430 So suppose we have two negative eigenvalues. 215 00:15:13,430 --> 00:15:21,630 Then certainly, this would mean the trace would be negative. 216 00:15:21,630 --> 00:15:25,110 Because the trace is the sum of the eigenvalues. 217 00:15:25,110 --> 00:15:29,320 If those are both negative, trace is negative. 218 00:15:29,320 --> 00:15:33,470 So we can check about the trace just right away. 219 00:15:33,470 --> 00:15:35,530 What about the determinant? 220 00:15:35,530 --> 00:15:38,660 If that's negative and that's negative, 221 00:15:38,660 --> 00:15:42,090 then multiplying those will give a positive number. 222 00:15:42,090 --> 00:15:44,600 So the determinant should be positive. 223 00:15:44,600 --> 00:15:47,320 So trace less than 0. 224 00:15:47,320 --> 00:15:50,680 Determinant greater than 0. 225 00:15:50,680 --> 00:15:53,550 That is the stability test. 226 00:15:53,550 --> 00:15:55,250 That's the stability test. 227 00:15:57,610 --> 00:15:58,110 Stable. 228 00:16:01,590 --> 00:16:06,230 The two by two matrix A, B, C, D, if its trace is negative 229 00:16:06,230 --> 00:16:09,780 and its determinant is positive, is stable. 230 00:16:09,780 --> 00:16:11,190 That's the test. 231 00:16:11,190 --> 00:16:16,690 And actually, it works also if lambda comes out complex 232 00:16:16,690 --> 00:16:24,280 because lambda 1 plus lambda 2-- lambda 1 is a plus i omega. 233 00:16:24,280 --> 00:16:26,840 Lambda 2 is a minus omega. 234 00:16:26,840 --> 00:16:30,130 The sum is just 2a. 235 00:16:30,130 --> 00:16:32,500 And we want that to be negative. 236 00:16:32,500 --> 00:16:35,530 So again, trace negative. 237 00:16:35,530 --> 00:16:40,830 Trace negative even if the roots are real or if they're complex. 238 00:16:40,830 --> 00:16:44,970 That still tells us that the sum of the roots is negative 239 00:16:44,970 --> 00:16:47,450 and the determinant also works. 240 00:16:47,450 --> 00:16:53,980 If a plus i omega times a minus i omega-- in this case, 241 00:16:53,980 --> 00:16:58,140 lambda 1 times lambda 2-- if I multiply those numbers, 242 00:16:58,140 --> 00:17:02,750 I get a squared plus omega squared. 243 00:17:02,750 --> 00:17:04,260 With a plus. 244 00:17:04,260 --> 00:17:06,079 So that would be positive. 245 00:17:06,079 --> 00:17:09,089 And we're good. 246 00:17:09,089 --> 00:17:16,890 So my conclusion is this is the test for stability. 247 00:17:16,890 --> 00:17:19,020 And I can apply it to a few matrices. 248 00:17:19,020 --> 00:17:21,990 I wrote down a few matrices. 249 00:17:21,990 --> 00:17:26,880 Can I just look at that test-- can you look at that test-- 250 00:17:26,880 --> 00:17:28,950 and just apply it to see. 251 00:17:31,980 --> 00:17:34,170 So here's an example. 252 00:17:34,170 --> 00:17:41,130 Say minus 2, minus 1, 3, and 4. 253 00:17:41,130 --> 00:17:42,740 Is that any good? 254 00:17:42,740 --> 00:17:45,470 The trace is minus 3. 255 00:17:45,470 --> 00:17:46,690 That's good. 256 00:17:46,690 --> 00:17:50,190 The determinant is 2 minus 12 minus 10. 257 00:17:50,190 --> 00:17:51,710 That's bad. 258 00:17:51,710 --> 00:17:52,850 That's bad. 259 00:17:52,850 --> 00:17:55,650 So that would be unstable. 260 00:17:58,460 --> 00:18:00,120 That has a negative determinant. 261 00:18:00,120 --> 00:18:01,570 Unstable. 262 00:18:01,570 --> 00:18:03,500 So I'll put an x through that. 263 00:18:03,500 --> 00:18:04,840 Unstable. 264 00:18:04,840 --> 00:18:07,210 Let me take a stable one. 265 00:18:07,210 --> 00:18:13,170 Stable one, I'm going to want like minus 5, and 1, let's say. 266 00:18:13,170 --> 00:18:14,620 That's OK. 267 00:18:14,620 --> 00:18:16,350 The trace is negative. 268 00:18:16,350 --> 00:18:17,710 Minus 4. 269 00:18:17,710 --> 00:18:21,250 And now I want to make the determinant positive. 270 00:18:21,250 --> 00:18:27,360 So maybe I better put like 6 and minus 7. 271 00:18:27,360 --> 00:18:28,940 Just picking numbers. 272 00:18:28,940 --> 00:18:36,550 So now the determinant is minus 5 plus 42. 273 00:18:36,550 --> 00:18:38,620 A big positive number. 274 00:18:38,620 --> 00:18:41,310 And the determinant test is passed. 275 00:18:41,310 --> 00:18:43,330 So that is OK. 276 00:18:43,330 --> 00:18:44,490 That one would be stable. 277 00:18:47,420 --> 00:18:52,500 If this was my matrix A, then the solutions 278 00:18:52,500 --> 00:19:01,450 to dy dt equal Ay, y prime equal Ay is my differential equation. 279 00:19:01,450 --> 00:19:06,610 The two solutions which would track the eigenvectors 280 00:19:06,610 --> 00:19:09,580 would have negative lambdas. 281 00:19:09,580 --> 00:19:13,120 Negative lambdas because the trace is negative 282 00:19:13,120 --> 00:19:15,590 and the determinant is positive. 283 00:19:15,590 --> 00:19:18,510 Passes the stability test and the solutions 284 00:19:18,510 --> 00:19:21,960 would go to minus infinity. 285 00:19:21,960 --> 00:19:23,900 That's two by twos. 286 00:19:23,900 --> 00:19:25,650 Thank you.