1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,763 The following content is provided under a Creative 3 00:00:02,763 --> 00:00:03,610 Commons license. 4 00:00:03,610 --> 00:00:05,770 Your support will help MIT OpenCourseWare 5 00:00:05,770 --> 00:00:09,370 continue to offer high quality educational resources for free. 6 00:00:09,370 --> 00:00:12,530 To make a donation, or to view additional materials 7 00:00:12,530 --> 00:00:16,150 from hundreds of MIT courses visit MIT OpenCourseWare 8 00:00:16,150 --> 00:00:19,390 at ocw.mit.edu. 9 00:00:19,390 --> 00:00:22,930 PROFESSOR STRANG: Ready? 10 00:00:22,930 --> 00:00:27,910 So let me recap the important lecture 11 00:00:27,910 --> 00:00:31,650 from last time that gave the framework that we'll 12 00:00:31,650 --> 00:00:33,480 see in Chapter two and Chapter three, 13 00:00:33,480 --> 00:00:35,640 really a major part of the course. 14 00:00:35,640 --> 00:00:39,990 And our example was a line of masses and springs. 15 00:00:39,990 --> 00:00:43,190 So that's like, the first example to start with. 16 00:00:43,190 --> 00:00:46,700 And you remember, there were three steps. 17 00:00:46,700 --> 00:00:50,240 If we want to know how much the masses displace 18 00:00:50,240 --> 00:00:54,350 we have to get to the springs. 19 00:00:54,350 --> 00:00:58,010 Difference in displacements gave the stretching of the springs. 20 00:00:58,010 --> 00:01:01,660 Then comes the material law, Hooke's Law in this case, 21 00:01:01,660 --> 00:01:06,160 with a matrix C that led to CAu. 22 00:01:06,160 --> 00:01:08,470 And then finally, those spring forces 23 00:01:08,470 --> 00:01:11,440 are balanced by the external forces. 24 00:01:11,440 --> 00:01:13,560 That brought in A transpose. 25 00:01:13,560 --> 00:01:17,540 So that's the picture to look for. 26 00:01:17,540 --> 00:01:27,430 And I just mention it again because it's so central. 27 00:01:27,430 --> 00:01:30,660 So we'll be doing other examples of that. 28 00:01:30,660 --> 00:01:35,330 But I wanted to stay with springs and masses for today. 29 00:01:35,330 --> 00:01:37,560 To do another type of problem. 30 00:01:37,560 --> 00:01:40,360 A problem in which time enters. 31 00:01:40,360 --> 00:01:44,610 A problem in which we're not looking for the steady state. 32 00:01:44,610 --> 00:01:47,470 But it's Newton's Law is going to come in. 33 00:01:47,470 --> 00:01:49,220 This is actually Newton's Law. 34 00:01:49,220 --> 00:01:51,790 You recognize mass. 35 00:01:51,790 --> 00:01:54,090 You recognize acceleration. 36 00:01:54,090 --> 00:01:59,380 And the force on the spring is -Ku. 37 00:01:59,380 --> 00:02:05,420 So when -Ku, when the force came over to that side, 38 00:02:05,420 --> 00:02:08,120 that's the equation we're looking at. 39 00:02:08,120 --> 00:02:12,810 So it's like time-out for a discussion 40 00:02:12,810 --> 00:02:16,290 of the very important subject of time derivatives. 41 00:02:16,290 --> 00:02:24,080 How do I solve initial value problems now? 42 00:02:24,080 --> 00:02:28,370 So I have some starting time, I'm 43 00:02:28,370 --> 00:02:32,780 given u(0), the starting position of the springs, 44 00:02:32,780 --> 00:02:37,600 and I'm given the velocity at zero. 45 00:02:37,600 --> 00:02:41,120 So I'm given two facts at zero. 46 00:02:41,120 --> 00:02:46,000 That's very different from the steady state problem 47 00:02:46,000 --> 00:02:48,420 where you're given stuff around the boundary. 48 00:02:48,420 --> 00:02:50,290 Here we're given stuff at the start. 49 00:02:50,290 --> 00:02:53,540 Initial values instead of boundary values. 50 00:02:53,540 --> 00:02:55,000 So what does this mean? 51 00:02:55,000 --> 00:03:00,130 It means that maybe I pull the springs down and I let go. 52 00:03:00,130 --> 00:03:02,080 And what do they do? 53 00:03:02,080 --> 00:03:02,900 They oscillate. 54 00:03:02,900 --> 00:03:05,830 And you will have studied this equation. 55 00:03:05,830 --> 00:03:08,600 I hope you've seen that equation. 56 00:03:08,600 --> 00:03:11,030 Because I think of it as the fundamental equation 57 00:03:11,030 --> 00:03:12,890 of mechanics. 58 00:03:12,890 --> 00:03:14,740 In fact, I've even used those words. 59 00:03:14,740 --> 00:03:17,990 The fundamental equation of mechanical engineering. 60 00:03:17,990 --> 00:03:24,290 Well, it's Newton's Law for a system. 61 00:03:24,290 --> 00:03:29,830 So the matrix M now has two masses. 62 00:03:29,830 --> 00:03:32,800 In this case, it would be a two by two system. 63 00:03:32,800 --> 00:03:35,660 The matrix M would have two masses. 64 00:03:35,660 --> 00:03:42,850 Suppose mass one may be like, nine and mass two is one. 65 00:03:42,850 --> 00:03:48,380 So copying what our problem is we'd have a nine and a one 66 00:03:48,380 --> 00:03:53,550 multiplying u_1'' and u_2''. 67 00:03:53,550 --> 00:03:57,160 Can I use prime for a derivative? 68 00:03:57,160 --> 00:03:59,430 Rather than dots, because I'm never 69 00:03:59,430 --> 00:04:01,820 too sure if the dot is there or not. 70 00:04:01,820 --> 00:04:04,690 So prime I can see. 71 00:04:04,690 --> 00:04:08,040 And then plus our Ku. 72 00:04:08,040 --> 00:04:13,860 And actually you know what K will look like for this system. 73 00:04:13,860 --> 00:04:17,020 It's fixed-fixed. 74 00:04:17,020 --> 00:04:20,700 Well, let me write down what K would look like. 75 00:04:20,700 --> 00:04:23,270 Just because we saw it at the very end. 76 00:04:23,270 --> 00:04:27,140 What it looks like if there are spring constants, c_1, c_2, 77 00:04:27,140 --> 00:04:27,950 and c_3. 78 00:04:27,950 --> 00:04:33,390 Can I just remind you what that will look like? 79 00:04:33,390 --> 00:04:36,310 So this will multiply u and give zero. 80 00:04:36,310 --> 00:04:43,930 So the mass matrix is diagonal in the problem. 81 00:04:43,930 --> 00:04:47,750 That's, diagonal matrices, we certainly expect to be easy. 82 00:04:47,750 --> 00:04:50,770 Almost as easy as the identity matrix 83 00:04:50,770 --> 00:04:53,320 where we would have two equal masses. 84 00:04:53,320 --> 00:04:55,620 Here it's just that little bit more general 85 00:04:55,620 --> 00:04:57,190 with two different masses. 86 00:04:57,190 --> 00:05:00,840 And in here, the kind of thing that we created just at the end 87 00:05:00,840 --> 00:05:05,560 of the last lecture was something like c_1+c_2 88 00:05:05,560 --> 00:05:12,830 on the diagonal and a -c_2 and a -c_2 and a c_2+c_3. 89 00:05:12,830 --> 00:05:16,110 90 00:05:16,110 --> 00:05:19,420 So c_2 for the middle spring is the one 91 00:05:19,420 --> 00:05:22,900 that's really there with its full little element matrix, 92 00:05:22,900 --> 00:05:26,570 c_2, -c2; -c_2, c_2. 93 00:05:26,570 --> 00:05:32,160 The c_1 part is only coming in at the top 94 00:05:32,160 --> 00:05:34,730 because it's connected to a fixed support. 95 00:05:34,730 --> 00:05:37,240 And c_3 is only coming in at the bottom. 96 00:05:37,240 --> 00:05:42,370 Anyway, that's the matrix K. This is the matrix M. 97 00:05:42,370 --> 00:05:46,020 And how do we solve the problem? 98 00:05:46,020 --> 00:05:50,350 You've seen before, and now ADINA Professor Bathe's code 99 00:05:50,350 --> 00:05:55,590 or any other code would offer, like, two different ways. 100 00:05:55,590 --> 00:06:02,470 One way is because we have constant coefficients here 101 00:06:02,470 --> 00:06:07,370 we can expect a pretty clean formula for the answer. 102 00:06:07,370 --> 00:06:12,830 And because we're growing, we're oscillating in time, 103 00:06:12,830 --> 00:06:16,320 things are happening in time, we expect eigenvectors, 104 00:06:16,320 --> 00:06:18,160 eigenvalues to come in. 105 00:06:18,160 --> 00:06:19,270 Into that formula. 106 00:06:19,270 --> 00:06:22,980 I think it's worth just repeating that formula. 107 00:06:22,980 --> 00:06:24,700 How do you approach it? 108 00:06:24,700 --> 00:06:28,860 And then the second, the really serious issue 109 00:06:28,860 --> 00:06:34,890 is how do you solve equation like this 110 00:06:34,890 --> 00:06:40,400 or even more general, time-dependent problems. 111 00:06:40,400 --> 00:06:43,410 I mean this is what finite element codes are created for. 112 00:06:43,410 --> 00:06:47,720 How do you study the crash of a car? 113 00:06:47,720 --> 00:06:52,170 So this isn't quite the equation for a car crash. 114 00:06:52,170 --> 00:06:57,360 What would be different in a car crash? 115 00:06:57,360 --> 00:07:02,370 There's a short section later in Chapter two 116 00:07:02,370 --> 00:07:05,340 called the reality of computational engineering. 117 00:07:05,340 --> 00:07:10,660 And the reality is, cars crash, people drop their cell phones. 118 00:07:10,660 --> 00:07:15,030 And those are very difficult problems to compute with. 119 00:07:15,030 --> 00:07:18,840 And of course, absolutely impossible to use eigenvectors 120 00:07:18,840 --> 00:07:22,040 because, well they're not linear at all. 121 00:07:22,040 --> 00:07:23,190 Right? 122 00:07:23,190 --> 00:07:26,440 If you crash two cars, if you want to study, 123 00:07:26,440 --> 00:07:28,850 everything's happening in like, a hundredth 124 00:07:28,850 --> 00:07:30,330 of a second or something. 125 00:07:30,330 --> 00:07:34,610 But what's happening there is highly non-linear 126 00:07:34,610 --> 00:07:37,330 so it's very much more complicated. 127 00:07:37,330 --> 00:07:40,030 And you take thousands of time steps 128 00:07:40,030 --> 00:07:43,050 maybe within the crash time. 129 00:07:43,050 --> 00:07:52,090 And you're going to use finite differences or finite elements. 130 00:07:52,090 --> 00:07:55,150 So this is a chance to say something 131 00:07:55,150 --> 00:08:02,120 about this special equation for finite difference method. 132 00:08:02,120 --> 00:08:06,870 It's really 18.086 that takes up these questions seriously. 133 00:08:06,870 --> 00:08:08,780 If I choose a finite difference method. 134 00:08:08,780 --> 00:08:11,290 See, the thing is with finite differences 135 00:08:11,290 --> 00:08:14,610 you've got many, many choices. 136 00:08:14,610 --> 00:08:17,710 There's only one way to go in step one. 137 00:08:17,710 --> 00:08:21,950 Eigenvectors, this thing has got eigenvectors, you find them, 138 00:08:21,950 --> 00:08:23,180 you're in. 139 00:08:23,180 --> 00:08:26,420 But for the much more general, typical problems 140 00:08:26,420 --> 00:08:29,450 that you'll be solving the rest of your lives, 141 00:08:29,450 --> 00:08:31,380 finite differences or finite elements, 142 00:08:31,380 --> 00:08:35,170 you've got lots of choices. 143 00:08:35,170 --> 00:08:41,270 And the issues that come up are the accuracy of the choice. 144 00:08:41,270 --> 00:08:43,590 Centered differences often gives you 145 00:08:43,590 --> 00:08:45,560 that extra order of accuracy. 146 00:08:45,560 --> 00:08:50,820 Stability is something we have not seen yet. 147 00:08:50,820 --> 00:08:52,500 So what does stability mean? 148 00:08:52,500 --> 00:08:56,900 Stability means that as I follow my difference equation forward 149 00:08:56,900 --> 00:09:02,250 in time it stays near the true equation. 150 00:09:02,250 --> 00:09:04,150 You'll see by example. 151 00:09:04,150 --> 00:09:06,820 So some methods are more stable than others, 152 00:09:06,820 --> 00:09:09,970 some are completely unstable and unusable. 153 00:09:09,970 --> 00:09:12,470 And then, of course, the other condition, 154 00:09:12,470 --> 00:09:19,230 another desired requirement, is speed of calculation. 155 00:09:19,230 --> 00:09:21,250 So these balance each other. 156 00:09:21,250 --> 00:09:23,200 It's a beautiful subject. 157 00:09:23,200 --> 00:09:28,850 And let me just open the door to that subject today. 158 00:09:28,850 --> 00:09:32,900 May I start with the eigenvector solution. 159 00:09:32,900 --> 00:09:37,110 How would I solve this equation by eigenvectors? 160 00:09:37,110 --> 00:09:42,780 Well again, I'm going to look for special solutions. 161 00:09:42,780 --> 00:09:46,460 So let me write that equation down again. 162 00:09:46,460 --> 00:09:47,020 Mu''+Ku=0. 163 00:09:47,020 --> 00:09:49,590 164 00:09:49,590 --> 00:09:53,140 I'm taking zero external force. 165 00:09:53,140 --> 00:09:57,090 So the springs and masses are just oscillating. 166 00:09:57,090 --> 00:10:00,770 Their total energy won't change, it's a closed system. 167 00:10:00,770 --> 00:10:04,260 The kinetic plus the potential energy will stay constant 168 00:10:04,260 --> 00:10:07,580 and we can show why. 169 00:10:07,580 --> 00:10:11,380 There's a lot in this section, by the way, section 2.2. 170 00:10:11,380 --> 00:10:13,650 More than I would be able to do in the lecture. 171 00:10:13,650 --> 00:10:17,210 But let me capture the key ideas. 172 00:10:17,210 --> 00:10:20,840 So one key idea is the natural idea when 173 00:10:20,840 --> 00:10:24,910 we have constant coefficients. 174 00:10:24,910 --> 00:10:26,970 Look for special solutions. 175 00:10:26,970 --> 00:10:32,270 So let me say look for special solutions of the form-- 176 00:10:32,270 --> 00:10:36,880 well, let's keep in mind always the simplest model of all. 177 00:10:36,880 --> 00:10:42,170 Let me put it over here because I'll focus on it particularly, 178 00:10:42,170 --> 00:10:43,370 especially. 179 00:10:43,370 --> 00:10:49,380 The simplest case would be u'', with a mass normalized to one, 180 00:10:49,380 --> 00:10:52,600 plus u equal 0. 181 00:10:52,600 --> 00:10:54,090 Just a single equation. 182 00:10:54,090 --> 00:10:57,910 So that's just a single spring. 183 00:10:57,910 --> 00:10:59,800 Single mass. 184 00:10:59,800 --> 00:11:02,570 So the mass is just oscillating up and down. 185 00:11:02,570 --> 00:11:07,940 And we all know that it's going to oscillate up and down, 186 00:11:07,940 --> 00:11:10,710 sines and cosines are going to come into here. 187 00:11:10,710 --> 00:11:12,810 In fact, we know that the solution 188 00:11:12,810 --> 00:11:18,950 to that would be, this could have cosine, this 189 00:11:18,950 --> 00:11:22,350 would have some cos(t)'s and some-- u 190 00:11:22,350 --> 00:11:29,330 could be a combination of cos(t) and sin(t). 191 00:11:29,330 --> 00:11:30,250 Right? 192 00:11:30,250 --> 00:11:34,240 And the A and B would be used to match the two 193 00:11:34,240 --> 00:11:35,670 initial conditions. 194 00:11:35,670 --> 00:11:38,050 So that's what we've got in the scalar case. 195 00:11:38,050 --> 00:11:44,390 This is one spring. n is one. 196 00:11:44,390 --> 00:11:47,490 We don't have a matrix here, just a number. 197 00:11:47,490 --> 00:11:53,330 But that's our guide to the matrix case. 198 00:11:53,330 --> 00:11:54,830 So now what am I going to look for? 199 00:11:54,830 --> 00:11:56,940 I'm going to look for u(t). 200 00:11:56,940 --> 00:12:04,530 I'll look for special solutions of the form cos-- 201 00:12:04,530 --> 00:12:06,700 They'll go at different frequencies. 202 00:12:06,700 --> 00:12:09,920 So the frequency has to be found. 203 00:12:09,920 --> 00:12:12,550 So that's the time dependence. 204 00:12:12,550 --> 00:12:17,640 And then some, if I'm lucky all the springs 205 00:12:17,640 --> 00:12:20,740 will be going together. 206 00:12:20,740 --> 00:12:25,850 So this x-- Am I going to use x for eigenvector? 207 00:12:25,850 --> 00:12:27,040 I think so, yes. 208 00:12:27,040 --> 00:12:30,180 Let's use x for eigenvector. 209 00:12:30,180 --> 00:12:37,690 So this is a vector, this is a constant vector. 210 00:12:37,690 --> 00:12:49,490 And this gives the oscillation. 211 00:12:49,490 --> 00:12:55,910 Let me just already start with that. 212 00:12:55,910 --> 00:12:57,550 I've got two unknowns here, right? 213 00:12:57,550 --> 00:12:59,760 Two things that I'm free to choose. 214 00:12:59,760 --> 00:13:02,400 I'm free to choose the frequency omega 215 00:13:02,400 --> 00:13:05,320 and I'm free to choose this vector x. 216 00:13:05,320 --> 00:13:08,240 And I've like, separated out time. 217 00:13:08,240 --> 00:13:12,850 The way we've been doing it with an e^(lambda*t). 218 00:13:12,850 --> 00:13:14,740 We used an e^(lambda*t). 219 00:13:14,740 --> 00:13:18,880 So that was sort of right for a first order equation. 220 00:13:18,880 --> 00:13:23,940 Cosine is right for a second order equation like this. 221 00:13:23,940 --> 00:13:26,770 When is that a solution to my equation? 222 00:13:26,770 --> 00:13:29,360 May I just plug it in? 223 00:13:29,360 --> 00:13:34,160 So I'm going to just plug it in? 224 00:13:34,160 --> 00:13:36,910 Substitute is a better word than plug in, right? 225 00:13:36,910 --> 00:13:42,170 So shall I just plug it in? 226 00:13:42,170 --> 00:13:46,810 So I get M times that second derivative. 227 00:13:46,810 --> 00:13:48,820 So the second derivative of the cosine 228 00:13:48,820 --> 00:13:54,390 is the cosine with a minus, M omega squared. 229 00:13:54,390 --> 00:13:56,580 Is that right? 230 00:13:56,580 --> 00:13:57,750 Yes? 231 00:13:57,750 --> 00:13:58,830 Times what? 232 00:13:58,830 --> 00:14:01,710 So that's what came from the time derivative. 233 00:14:01,710 --> 00:14:04,540 Times cos times this, cos(omega*t)x. 234 00:14:04,540 --> 00:14:08,040 235 00:14:08,040 --> 00:14:11,550 Two time derivatives brought down a minus omega squared. 236 00:14:11,550 --> 00:14:16,440 And the other part is just K times u, cos(omega*t)x. 237 00:14:16,440 --> 00:14:19,880 238 00:14:19,880 --> 00:14:24,270 And that should be zero. 239 00:14:24,270 --> 00:14:27,130 And this is supposed to be a good solution that 240 00:14:27,130 --> 00:14:33,780 works for all time. 241 00:14:33,780 --> 00:14:37,470 This is what I want to be zero. 242 00:14:37,470 --> 00:14:39,330 Do you see what's left? 243 00:14:39,330 --> 00:14:45,310 Kx from here. 244 00:14:45,310 --> 00:14:53,240 And putting that on the other side, M omega squared x. 245 00:14:53,240 --> 00:14:56,140 Can I write the omega squared that way? omega squared Mx. 246 00:14:56,140 --> 00:14:59,510 247 00:14:59,510 --> 00:15:05,015 Then if that is satisfied then the differential equation 248 00:15:05,015 --> 00:15:05,850 is satisfied. 249 00:15:05,850 --> 00:15:06,960 I've got a solution. 250 00:15:06,960 --> 00:15:10,970 So I'm looking for K and I'm looking for x and omega. 251 00:15:10,970 --> 00:15:16,940 And by the way, I could also have sin(omega*t) here. 252 00:15:16,940 --> 00:15:19,660 As well as cosine just the way over there. 253 00:15:19,660 --> 00:15:22,140 Sines and cosines both possible. 254 00:15:22,140 --> 00:15:22,870 So sin(omega*t)x. 255 00:15:22,870 --> 00:15:26,320 256 00:15:26,320 --> 00:15:28,620 It would be exactly the same except that it'd be 257 00:15:28,620 --> 00:15:31,520 a sin(omega*t) that I'd be dividing out. 258 00:15:31,520 --> 00:15:33,750 And again, I'd come back to this. 259 00:15:33,750 --> 00:15:39,640 This is key problem. 260 00:15:39,640 --> 00:15:44,760 And do you see that somehow here we have an eigenvector x 261 00:15:44,760 --> 00:15:48,850 and an eigenvalue omega squared? 262 00:15:48,850 --> 00:15:54,110 An eigenvalue omega squared, right. 263 00:15:54,110 --> 00:15:55,460 But there is one little twist. 264 00:15:55,460 --> 00:15:59,590 It's not quite our standard eigenvalue problem. 265 00:15:59,590 --> 00:16:03,860 What's the extra guy that's present in that box 266 00:16:03,860 --> 00:16:07,500 that we don't usually see? 267 00:16:07,500 --> 00:16:11,960 M. M is the new person there, new thing. 268 00:16:11,960 --> 00:16:13,220 The mass matrix. 269 00:16:13,220 --> 00:16:17,660 Which, if all masses where one, the mass matrix 270 00:16:17,660 --> 00:16:18,740 would be the identity. 271 00:16:18,740 --> 00:16:19,730 We would be back. 272 00:16:19,730 --> 00:16:21,870 We would just have our standard problem. 273 00:16:21,870 --> 00:16:25,810 I just have to say a word about the case 274 00:16:25,810 --> 00:16:29,780 when the mass matrix is there. 275 00:16:29,780 --> 00:16:32,370 It's still an eigenvalue problem. 276 00:16:32,370 --> 00:16:37,000 If you like, I can bring M inverse over here. 277 00:16:37,000 --> 00:16:43,180 I could write it as M inverse K x equal omega squared x. 278 00:16:43,180 --> 00:16:49,490 So I'm looking for the eigenvalues of M inverse K. 279 00:16:49,490 --> 00:16:51,640 That's really what I'm doing. 280 00:16:51,640 --> 00:16:55,230 The eigenvalues and eigenvectors of M inverse K. 281 00:16:55,230 --> 00:17:03,610 But I'm always trying to be like, aesthetically right. 282 00:17:03,610 --> 00:17:09,210 And what's-- M inverse K has just a little something wrong 283 00:17:09,210 --> 00:17:09,710 with it. 284 00:17:09,710 --> 00:17:11,720 Which is? 285 00:17:11,720 --> 00:17:14,620 It's not symmetric. 286 00:17:14,620 --> 00:17:18,320 If I take my matrix K, which is beautifully symmetric, 287 00:17:18,320 --> 00:17:20,530 and my M, which is beautifully symmetric, 288 00:17:20,530 --> 00:17:23,740 but when I do M inverse K, do you see what'll happen? 289 00:17:23,740 --> 00:17:27,290 The inverse of that matrix will have a 1/9. 290 00:17:27,290 --> 00:17:31,650 When I do M inverse*K, that row will get divided by nine. 291 00:17:31,650 --> 00:17:35,380 And the second row won't change because I've got a one. 292 00:17:35,380 --> 00:17:39,180 So it just like, spoiled things a little. 293 00:17:39,180 --> 00:17:41,250 You can deal with it. 294 00:17:41,250 --> 00:17:46,030 But actually, in some way it's better to keep it right. 295 00:17:46,030 --> 00:17:50,120 And MATLAB is totally okay with that. 296 00:17:50,120 --> 00:17:54,930 So MATLAB would use the command eig -- and other systems too -- 297 00:17:54,930 --> 00:18:03,140 of K, M. Just tell MATLAB the two matrices. 298 00:18:03,140 --> 00:18:06,300 Then it solves that problem. 299 00:18:06,300 --> 00:18:10,450 It will print out the, well if you just typed eig, 300 00:18:10,450 --> 00:18:13,790 it would print out the eigenvalues. 301 00:18:13,790 --> 00:18:16,810 If you ask it for the eigenvector matrix, 302 00:18:16,810 --> 00:18:18,380 it'll print those too. 303 00:18:18,380 --> 00:18:24,590 So that has the grand name generalized eigenvalue problem. 304 00:18:24,590 --> 00:18:27,380 Generalized because it's got an M in there. 305 00:18:27,380 --> 00:18:30,970 I don't know if you've met these problems where there could 306 00:18:30,970 --> 00:18:34,710 be an M. It's just a natural, and it's not really 307 00:18:34,710 --> 00:18:39,000 a big deal, particularly when M is a positive diagonal matrix. 308 00:18:39,000 --> 00:18:40,850 It's not a big deal at all. 309 00:18:40,850 --> 00:18:45,860 It's the same codes essentially finding the eigenvalues 310 00:18:45,860 --> 00:18:48,230 and eigenvectors. 311 00:18:48,230 --> 00:18:52,050 So suppose we have them. 312 00:18:52,050 --> 00:19:01,200 We expect n positive eigenvalues, 313 00:19:01,200 --> 00:19:04,980 and those'll be the omega squareds. 314 00:19:04,980 --> 00:19:08,670 And each one comes with its eigenvector. 315 00:19:08,670 --> 00:19:14,110 And complete set, everything is good. 316 00:19:14,110 --> 00:19:17,460 We're talking about symmetric positive definite matrices. 317 00:19:17,460 --> 00:19:21,300 Notice that K is positive definite. 318 00:19:21,300 --> 00:19:25,800 That was what our whole last weeks have been about. 319 00:19:25,800 --> 00:19:28,770 And M is obviously positive definite. 320 00:19:28,770 --> 00:19:34,660 So it's a complete-- it's a perfect set-up 321 00:19:34,660 --> 00:19:37,570 for the eigenvalue problem. 322 00:19:37,570 --> 00:19:41,160 I just want to think through the final step. 323 00:19:41,160 --> 00:19:46,560 After we find the eigenvalues, lambda, the omega squareds, 324 00:19:46,560 --> 00:19:51,370 then we know the omegas and we find the eigenvectors, x, 325 00:19:51,370 --> 00:19:56,610 how do you write the answer? 326 00:19:56,610 --> 00:19:59,000 So what have I done so far? 327 00:19:59,000 --> 00:20:03,030 I've looked for some special solutions. 328 00:20:03,030 --> 00:20:06,170 And I will find them. 329 00:20:06,170 --> 00:20:09,140 So I've found these omegas. 330 00:20:09,140 --> 00:20:13,460 They can go with sines or cosines, I found the x's. 331 00:20:13,460 --> 00:20:17,210 Now what's the general solution? 332 00:20:17,210 --> 00:20:20,650 If I have these solutions to my great equation 333 00:20:20,650 --> 00:20:23,710 there, what's the general solution? u(t). 334 00:20:23,710 --> 00:20:30,160 So this would be the big picture. 335 00:20:30,160 --> 00:20:35,270 What can I do in linear equations? 336 00:20:35,270 --> 00:20:37,130 Linear combinations. 337 00:20:37,130 --> 00:20:40,270 That's what linear algebra is all about, linear combinations. 338 00:20:40,270 --> 00:20:44,750 So I could take a linear combination of these cosines, 339 00:20:44,750 --> 00:20:49,160 so cos(omega_1*t)x_1. 340 00:20:49,160 --> 00:20:51,740 So that would be a solution coming 341 00:20:51,740 --> 00:20:56,560 from the first eigenvector and eigenvalue, or the square root, 342 00:20:56,560 --> 00:20:58,120 times any constant. 343 00:20:58,120 --> 00:21:01,740 And then, of course, I could have a b_1. 344 00:21:01,740 --> 00:21:05,300 I'll use b's for the sines. 345 00:21:05,300 --> 00:21:08,610 (omega_1*t), x_1. 346 00:21:08,610 --> 00:21:10,670 So that's just like that. 347 00:21:10,670 --> 00:21:15,240 But it's used the sines, which would also solve the equation. 348 00:21:15,240 --> 00:21:19,770 And then all the way down to x_n's. 349 00:21:19,770 --> 00:21:21,240 Right? 350 00:21:21,240 --> 00:21:23,750 So I've got 2n. 351 00:21:23,750 --> 00:21:30,810 2n simple solutions. n cosines times eigenvectors and n sines 352 00:21:30,810 --> 00:21:32,880 times those same eigenvectors. 353 00:21:32,880 --> 00:21:36,360 Why do I want 2n? 354 00:21:36,360 --> 00:21:41,360 I've got 2n constants then to choose, the a's and the b's. 355 00:21:41,360 --> 00:21:44,160 And how do I choose them? 356 00:21:44,160 --> 00:21:53,070 What's the next step? 357 00:21:53,070 --> 00:22:03,460 Using eigenvectors, maybe I just mention again the three steps. 358 00:22:03,460 --> 00:22:09,420 The three step method. 359 00:22:09,420 --> 00:22:19,710 Step one: find a's and b's. 360 00:22:19,710 --> 00:22:23,216 Oh, now you have to answer my question. 361 00:22:23,216 --> 00:22:25,090 Where are the a's and b's going to come from? 362 00:22:25,090 --> 00:22:28,560 What's going to determine these 2n constants, 363 00:22:28,560 --> 00:22:30,100 the a's and the b's? 364 00:22:30,100 --> 00:22:32,780 The initial conditions, of course. 365 00:22:32,780 --> 00:22:36,320 We've got two initial conditions, this is a vector. 366 00:22:36,320 --> 00:22:37,860 We're talking about a system here. 367 00:22:37,860 --> 00:22:41,910 I've got position of both masses. 368 00:22:41,910 --> 00:22:45,880 I've got the initial velocity of both masses. 369 00:22:45,880 --> 00:22:52,840 And the a's, they come from, because the a's go 370 00:22:52,840 --> 00:22:57,800 with the cosines and so they're going to be the ones associated 371 00:22:57,800 --> 00:23:01,330 with u(0), will give this. 372 00:23:01,330 --> 00:23:09,780 Will give a combination-- Will give the a's. u(0) will be 373 00:23:09,780 --> 00:23:15,690 a_1*x_1 + a_n*x_n. 374 00:23:15,690 --> 00:23:16,670 This is at t=0. 375 00:23:16,670 --> 00:23:19,610 376 00:23:19,610 --> 00:23:22,040 So I'm using the initial conditions. 377 00:23:22,040 --> 00:23:26,170 u(0) is a combination of those eigenvectors. 378 00:23:26,170 --> 00:23:32,510 So this is from the initial conditions. 379 00:23:32,510 --> 00:23:36,860 And the b's of course are going to come from u'(0), the initial 380 00:23:36,860 --> 00:23:40,330 velocity, because they go with sines. 381 00:23:40,330 --> 00:23:47,020 So sines start at zero but they have an initial velocity. 382 00:23:47,020 --> 00:23:50,920 So that's step one. 383 00:23:50,920 --> 00:23:53,550 That finds the constants. 384 00:23:53,550 --> 00:23:57,450 It splits the problem into these normal modes. 385 00:23:57,450 --> 00:24:00,560 It finds how much of each eigenvector 386 00:24:00,560 --> 00:24:04,260 is in there at the start. 387 00:24:04,260 --> 00:24:05,450 Step two? 388 00:24:05,450 --> 00:24:07,820 So it's really worth seeing these three steps 389 00:24:07,820 --> 00:24:11,090 because they just repeat and repeat for all applications 390 00:24:11,090 --> 00:24:12,230 of eigenvalues. 391 00:24:12,230 --> 00:24:15,670 Step two is what? 392 00:24:15,670 --> 00:24:20,300 Step two is follow each of these guys forward in time. 393 00:24:20,300 --> 00:24:22,810 Follow them to any time. 394 00:24:22,810 --> 00:24:23,870 What does that mean? 395 00:24:23,870 --> 00:24:28,500 That means just put in the cosines and the sines. 396 00:24:28,500 --> 00:24:44,260 So the a's go to a*cos(omega*t). 397 00:24:44,260 --> 00:24:48,300 So I'm just saying what happens to those coefficients. 398 00:24:48,300 --> 00:24:48,950 Each one. 399 00:24:48,950 --> 00:24:57,910 Let's see. a_i, say, goes to a_i is multiplied by the cosine. 400 00:24:57,910 --> 00:25:03,850 And the b's, b_i's go to b_i*sin(omega_i*t). 401 00:25:03,850 --> 00:25:08,170 402 00:25:08,170 --> 00:25:13,840 So now we followed the coefficients forward in time. 403 00:25:13,840 --> 00:25:15,830 And step three? 404 00:25:15,830 --> 00:25:19,380 The final step is? 405 00:25:19,380 --> 00:25:21,670 So here, we're following each one. 406 00:25:21,670 --> 00:25:25,260 So the pattern is always the same one. 407 00:25:25,260 --> 00:25:31,370 Take your starting conditions, split them up 408 00:25:31,370 --> 00:25:34,990 into eigenvectors. 409 00:25:34,990 --> 00:25:37,050 Follow each eigenvector. 410 00:25:37,050 --> 00:25:39,520 And then step three is? 411 00:25:39,520 --> 00:25:40,790 Reassemble. 412 00:25:40,790 --> 00:25:42,010 Put them back together. 413 00:25:42,010 --> 00:25:49,974 Step three is the solution. u at that later time t is 414 00:25:49,974 --> 00:25:50,890 a_1*cos(omega_1*t)x_1. 415 00:25:50,890 --> 00:25:54,510 416 00:25:54,510 --> 00:25:57,150 And b_1*sin(omega_1*t)x_1. 417 00:25:57,150 --> 00:26:00,720 418 00:26:00,720 --> 00:26:06,210 Those are the two guys that are reflecting 419 00:26:06,210 --> 00:26:08,040 the fundamental mode. 420 00:26:08,040 --> 00:26:14,700 And then we have a_2's and b_2's multiplied by cosines and sines 421 00:26:14,700 --> 00:26:18,650 and times x_2 and so on. 422 00:26:18,650 --> 00:26:22,160 Put the pieces together. 423 00:26:22,160 --> 00:26:24,920 So it's split the initial conditions, 424 00:26:24,920 --> 00:26:31,340 follow each eigenvector, reassemble. 425 00:26:31,340 --> 00:26:35,830 It's the heart of Fourier methods, 426 00:26:35,830 --> 00:26:38,720 it's the heart of using eigenvectors. 427 00:26:38,720 --> 00:26:49,610 And there's a little code in the book that does exactly that. 428 00:26:49,610 --> 00:26:51,920 So let's just pause a moment. 429 00:26:51,920 --> 00:26:54,900 This was the eigenvector solution. 430 00:26:54,900 --> 00:27:04,840 And now I want to talk about computational science. 431 00:27:04,840 --> 00:27:06,750 For which this problem is a model, 432 00:27:06,750 --> 00:27:12,870 but the problem has probably got more complications and things 433 00:27:12,870 --> 00:27:19,870 change in time, whatever. 434 00:27:19,870 --> 00:27:22,740 This was an exact solution. 435 00:27:22,740 --> 00:27:28,670 That's more than we hope for in real computations. 436 00:27:28,670 --> 00:27:32,860 We hope for accuracy, but we don't hope for 100% accuracy 437 00:27:32,860 --> 00:27:38,570 unless we have this exact model problem. 438 00:27:38,570 --> 00:27:40,680 So we use finite differences. 439 00:27:40,680 --> 00:27:45,550 Ready for finite differences? 440 00:27:45,550 --> 00:27:50,610 So this is method one, which allows you to understand 441 00:27:50,610 --> 00:27:52,030 the model problem. 442 00:27:52,030 --> 00:27:56,120 And now comes method two, which allows you to compute 443 00:27:56,120 --> 00:28:00,220 much more, many more problems. 444 00:28:00,220 --> 00:28:03,850 And if I do it just for this, let me come back 445 00:28:03,850 --> 00:28:06,610 to just this model. 446 00:28:06,610 --> 00:28:14,390 One spring and one mass. 447 00:28:14,390 --> 00:28:22,540 Shall we start the mass at rest? 448 00:28:22,540 --> 00:28:26,960 Let me make that the answer. 449 00:28:26,960 --> 00:28:28,400 I want that to be the answer. 450 00:28:28,400 --> 00:28:34,960 So I'm going to start with u(0) to be zero-- to be one, right? 451 00:28:34,960 --> 00:28:39,990 I'm going to start with u(0) to be one and u'(0) to be zero. 452 00:28:39,990 --> 00:28:42,870 Because the cosine starts at one and its derivative 453 00:28:42,870 --> 00:28:47,030 starts at zero. 454 00:28:47,030 --> 00:28:50,090 Apologies that this is such a simple model. 455 00:28:50,090 --> 00:28:54,390 I'm just pulling this this mass down and let go. 456 00:28:54,390 --> 00:28:58,310 I just pull it down an amount one, I let go, 457 00:28:58,310 --> 00:29:05,980 it oscillates forever. 458 00:29:05,980 --> 00:29:14,130 How do I draw the motion of a single mass? 459 00:29:14,130 --> 00:29:16,170 A picture is important and we have 460 00:29:16,170 --> 00:29:18,480 to think what's in the picture. 461 00:29:18,480 --> 00:29:26,150 So I think the picture should be, maybe u in this direction 462 00:29:26,150 --> 00:29:29,480 and maybe u' in this direction. 463 00:29:29,480 --> 00:29:33,600 So it's the u, u' plane. 464 00:29:33,600 --> 00:29:36,200 The position-velocity plane. 465 00:29:36,200 --> 00:29:38,380 Sometimes called the phase plane. 466 00:29:38,380 --> 00:29:42,570 I'll just write that word down, phase plane. 467 00:29:42,570 --> 00:29:45,090 And what will be our picture here? 468 00:29:45,090 --> 00:29:50,200 It starts there, right? u(0) is one, no velocity, starts there. 469 00:29:50,200 --> 00:29:52,770 Oh, and then it just follows cos(t). 470 00:29:52,770 --> 00:29:55,210 And of course, I know what u' is. 471 00:29:55,210 --> 00:29:59,540 If u is cos(t), u' is -sin(t). 472 00:29:59,540 --> 00:30:03,820 473 00:30:03,820 --> 00:30:07,790 Let me put that somewhere where my picture won't run over it, 474 00:30:07,790 --> 00:30:10,620 up here maybe. u' is -sin(t). 475 00:30:10,620 --> 00:30:16,720 476 00:30:16,720 --> 00:30:18,710 Help me out. 477 00:30:18,710 --> 00:30:23,510 If as time increases, I follow this point, 478 00:30:23,510 --> 00:30:26,110 the x-coordinate is cos(t). 479 00:30:26,110 --> 00:30:29,620 The y-coordinate is -sin(t). 480 00:30:29,620 --> 00:30:31,530 It's a circle. 481 00:30:31,530 --> 00:30:33,050 It's a circle. 482 00:30:33,050 --> 00:30:35,830 So I just buzz along it, because of that minus sign, 483 00:30:35,830 --> 00:30:37,980 the circle goes this way around. 484 00:30:37,980 --> 00:30:41,370 It's a unit circle. 485 00:30:41,370 --> 00:30:45,970 Goes on forever. 486 00:30:45,970 --> 00:30:48,760 And actually cos squared plus sine squared 487 00:30:48,760 --> 00:30:52,420 is one, of course, that's why it's a circle of radius one. 488 00:30:52,420 --> 00:30:58,450 And that represents the total energy actually. 489 00:30:58,450 --> 00:31:00,390 I'm trying to draw a circle. 490 00:31:00,390 --> 00:31:07,490 Actually how would you get your computer to draw a circle? 491 00:31:07,490 --> 00:31:09,640 I'm thinking not just one circle. 492 00:31:09,640 --> 00:31:11,810 I want to refresh it. 493 00:31:11,810 --> 00:31:14,080 I mean, I want to follow this in time. 494 00:31:14,080 --> 00:31:23,440 So I want to draw, I want to follow a point around a circle. 495 00:31:23,440 --> 00:31:25,380 Well I suppose what you would do would be 496 00:31:25,380 --> 00:31:29,740 to ask it to plot those points. 497 00:31:29,740 --> 00:31:31,490 That's not allowed. 498 00:31:31,490 --> 00:31:37,600 I want you to follow the solution to the equation. 499 00:31:37,600 --> 00:31:41,190 I want to take that equation whose exact solution is 500 00:31:41,190 --> 00:31:45,950 a circle and I want to use finite differences in time. 501 00:31:45,950 --> 00:31:48,460 So I'm going to take finite steps. 502 00:31:48,460 --> 00:31:50,420 Of course that's what the computer has to do. 503 00:31:50,420 --> 00:31:54,280 The computer will take finite steps. 504 00:31:54,280 --> 00:31:58,310 So I'd be very happy if those finite steps keep me 505 00:31:58,310 --> 00:32:00,270 on the circle. 506 00:32:00,270 --> 00:32:03,730 And I'd be even happier if it came around exactly right 507 00:32:03,730 --> 00:32:12,910 at 2pi but it's not going to. 508 00:32:12,910 --> 00:32:15,450 I want finite differences. 509 00:32:15,450 --> 00:32:17,950 I want to replace that differential equation 510 00:32:17,950 --> 00:32:19,330 by finite differences. 511 00:32:19,330 --> 00:32:23,110 And when we do this equation, we're 512 00:32:23,110 --> 00:32:26,440 practically doing that one at the same time. 513 00:32:26,440 --> 00:32:33,130 So this model will be fine. 514 00:32:33,130 --> 00:32:37,070 So I'm going to introduce finite differences for this equation. 515 00:32:37,070 --> 00:32:38,940 And everybody, we've been talking 516 00:32:38,940 --> 00:32:41,010 about how to replace second derivatives 517 00:32:41,010 --> 00:32:43,860 by second differences. 518 00:32:43,860 --> 00:32:49,600 So that looks good. 519 00:32:49,600 --> 00:32:52,580 Let me write down, maybe I can write down 520 00:32:52,580 --> 00:32:57,420 three or four possible finite differences. 521 00:32:57,420 --> 00:33:07,300 For u'' I think I'll write down u_(n+1) - 2u_n + u_(n-1). 522 00:33:07,300 --> 00:33:08,940 That's the second difference that 523 00:33:08,940 --> 00:33:12,290 replaces the second derivative, divided by what? 524 00:33:12,290 --> 00:33:20,120 What do you think goes in the denominator now? 525 00:33:20,120 --> 00:33:21,170 Square of what? 526 00:33:21,170 --> 00:33:23,390 Yeah, now what's the right name? 527 00:33:23,390 --> 00:33:25,480 It's going to be something squared. 528 00:33:25,480 --> 00:33:28,780 What do I put down there? 529 00:33:28,780 --> 00:33:31,540 The step size. 530 00:33:31,540 --> 00:33:33,460 I don't want to call it delta x, right? 531 00:33:33,460 --> 00:33:35,280 What should I call that? 532 00:33:35,280 --> 00:33:39,970 Delta t would be natural, delta t. 533 00:33:39,970 --> 00:33:44,350 Or h, I could again use h just to have a shorthand. 534 00:33:44,350 --> 00:33:47,150 That's my second difference. 535 00:33:47,150 --> 00:33:50,110 It's centered, it's the natural choice. 536 00:33:50,110 --> 00:33:52,230 And not the only choice, by the way. 537 00:33:52,230 --> 00:33:55,280 Oh. 538 00:33:55,280 --> 00:33:59,600 If I'm an astronomer or like, Professor Wisdom here. 539 00:33:59,600 --> 00:34:05,720 So he followed Pluto around, right? 540 00:34:05,720 --> 00:34:08,890 And discovered that Pluto wasn't a planet, right? 541 00:34:08,890 --> 00:34:11,030 He discovered that the motion of Pluto 542 00:34:11,030 --> 00:34:14,970 was not like, regular like the Earth. 543 00:34:14,970 --> 00:34:18,090 I think the Earth is regular. 544 00:34:18,090 --> 00:34:20,300 But Pluto has chaotic motion. 545 00:34:20,300 --> 00:34:22,280 So it does crazy stuff. 546 00:34:22,280 --> 00:34:24,010 Right. 547 00:34:24,010 --> 00:34:30,970 Well we're looking for very periodic, circular motion here. 548 00:34:30,970 --> 00:34:35,040 So what I was going to say, Professor Wisdom, he 549 00:34:35,040 --> 00:34:37,930 would sneer at this second differences, right? 550 00:34:37,930 --> 00:34:43,020 I mean, as we'll see that's got decent accuracy, but not 551 00:34:43,020 --> 00:34:45,130 accuracy that would allow you to follow 552 00:34:45,130 --> 00:34:50,020 Pluto for 100 million years. 553 00:34:50,020 --> 00:34:51,170 But it'll do for us. 554 00:34:51,170 --> 00:34:54,520 We're not going 100 million years here. 555 00:34:54,520 --> 00:34:58,960 So now comes -u. 556 00:34:58,960 --> 00:35:02,550 Now, question. 557 00:35:02,550 --> 00:35:05,330 I'm taking this, the u term and I'm 558 00:35:05,330 --> 00:35:07,090 putting it on the other side. 559 00:35:07,090 --> 00:35:10,090 So mass is one. 560 00:35:10,090 --> 00:35:12,800 Acceleration is this. 561 00:35:12,800 --> 00:35:15,450 The force is -u. 562 00:35:15,450 --> 00:35:23,410 Now comes the big question. 563 00:35:23,410 --> 00:35:26,750 For -u, do I use the newest value? 564 00:35:26,750 --> 00:35:28,680 Do I use the middle value? 565 00:35:28,680 --> 00:35:31,740 Or do I use the oldest value? 566 00:35:31,740 --> 00:35:34,320 Or some combination? 567 00:35:34,320 --> 00:35:37,100 If I want high accuracy, oh, then I 568 00:35:37,100 --> 00:35:40,600 go way up in these differences and I 569 00:35:40,600 --> 00:35:45,010 find tricky combinations that get me above first 570 00:35:45,010 --> 00:35:46,530 and second order accuracy. 571 00:35:46,530 --> 00:35:48,370 But let's not go there. 572 00:35:48,370 --> 00:35:53,670 So I've got to make one of those choices. 573 00:35:53,670 --> 00:35:58,020 And that choice is going to decide, so I mean, 574 00:35:58,020 --> 00:35:59,460 this is a choice you have to make 575 00:35:59,460 --> 00:36:01,740 when you have such a problem. 576 00:36:01,740 --> 00:36:04,990 Where are you going to evaluate this? 577 00:36:04,990 --> 00:36:08,550 I guess one choice jumps out as natural. 578 00:36:08,550 --> 00:36:16,750 What would you think of doing? 579 00:36:16,750 --> 00:36:20,060 Well how many would do that one? 580 00:36:20,060 --> 00:36:23,000 So those are people, that's the conservative choice, 581 00:36:23,000 --> 00:36:28,550 the stable. 582 00:36:28,550 --> 00:36:30,510 And then, how many would do this? 583 00:36:30,510 --> 00:36:33,010 Yeah, you would do that, right. 584 00:36:33,010 --> 00:36:35,450 I would call that the leapfrog choice. 585 00:36:35,450 --> 00:36:38,950 Somehow, this second difference is 586 00:36:38,950 --> 00:36:41,460 leaping over this middle point. 587 00:36:41,460 --> 00:36:43,750 So that would be the leapfrog method. 588 00:36:43,750 --> 00:36:52,620 And then if I use a very low-- to use the first value 589 00:36:52,620 --> 00:36:58,420 would be-- So my point is those are three different choices. 590 00:36:58,420 --> 00:37:04,810 And each one has these questions of accuracy. 591 00:37:04,810 --> 00:37:08,690 The middle one will be more accurate because it's centered. 592 00:37:08,690 --> 00:37:11,390 Each one has a question of stability. 593 00:37:11,390 --> 00:37:14,440 Ah, you don't see stability yet. 594 00:37:14,440 --> 00:37:18,680 So that's the point of the rest of the lecture is to see. 595 00:37:18,680 --> 00:37:21,210 What is this stability question? 596 00:37:21,210 --> 00:37:30,060 The issue of speed, speed would be, this is the slow one. 597 00:37:30,060 --> 00:37:35,010 Because it involves, I have to bring u_(n+1) over there. 598 00:37:35,010 --> 00:37:39,140 And if I've got a system of equations and then I, 599 00:37:39,140 --> 00:37:41,750 it would take me some time. 600 00:37:41,750 --> 00:37:48,040 This would be called an implicit method. 601 00:37:48,040 --> 00:37:52,770 The new u_(n+1) is only given implicitly because it's showing 602 00:37:52,770 --> 00:37:54,010 up on the right-hand side. 603 00:37:54,010 --> 00:37:56,000 I've got to move it over to the left. 604 00:37:56,000 --> 00:38:00,670 If it's non-linear I've got a system to solve. 605 00:38:00,670 --> 00:38:05,350 It's safer, but more expensive. 606 00:38:05,350 --> 00:38:11,250 But this would be the natural choice. 607 00:38:11,250 --> 00:38:19,680 I want to get eigenvalues into this picture. 608 00:38:19,680 --> 00:38:23,150 So I'm going to do the step we often do when 609 00:38:23,150 --> 00:38:26,330 we see a second order equation. 610 00:38:26,330 --> 00:38:30,290 That is, reduce it to two first order equations. 611 00:38:30,290 --> 00:38:33,360 Can I do that and see the same thing? 612 00:38:33,360 --> 00:38:36,730 So what would be my two first order equations. 613 00:38:36,730 --> 00:38:38,720 My unknowns will be u and u'. 614 00:38:38,720 --> 00:38:46,530 So it'll be first order, the derivative of u and u'. 615 00:38:46,530 --> 00:38:49,690 Shall I call it v for velocity? 616 00:38:49,690 --> 00:38:53,670 Let me write down, I don't need to write this fancy. 617 00:38:53,670 --> 00:39:05,100 The two equations will be, u'=v. And v' is what? 618 00:39:05,100 --> 00:39:10,290 So u'=v sort of told me what v was. v is the velocity, 619 00:39:10,290 --> 00:39:12,680 the time derivative of du/dt. 620 00:39:12,680 --> 00:39:15,370 And now the derivative of the velocity, now that 621 00:39:15,370 --> 00:39:17,840 should reflect my true equation. 622 00:39:17,840 --> 00:39:20,910 So this is all coming from u''+u=0. 623 00:39:20,910 --> 00:39:24,190 624 00:39:24,190 --> 00:39:29,680 So v' is what? v' is u''. 625 00:39:29,680 --> 00:39:32,730 Do I want -u there? 626 00:39:32,730 --> 00:39:39,230 Yeah, that's my equation. v', which is u'', is -u. 627 00:39:39,230 --> 00:39:39,740 Good. 628 00:39:39,740 --> 00:39:41,800 That's my system. 629 00:39:41,800 --> 00:39:44,270 So I have a matrix here. 630 00:39:44,270 --> 00:39:51,670 I have a two by two system with a matrix [0, 1; -1, 0] I guess. 631 00:39:51,670 --> 00:39:57,310 So while thinking about difference methods-- So this, 632 00:39:57,310 --> 00:39:59,880 I was thinking about a second order equation. 633 00:39:59,880 --> 00:40:01,580 I went right to it. 634 00:40:01,580 --> 00:40:04,500 Here I'm thinking about a first order system. 635 00:40:04,500 --> 00:40:07,690 A lot of problems come in first order systems. 636 00:40:07,690 --> 00:40:10,460 Gas dynamics comes as a big first order 637 00:40:10,460 --> 00:40:16,920 system for those components of mass, momentum, energy, 638 00:40:16,920 --> 00:40:23,150 typically five non-linear equations in gas dynamics. 639 00:40:23,150 --> 00:40:25,970 I mean, that's a very, very serious problem, 640 00:40:25,970 --> 00:40:28,050 how to solve those. 641 00:40:28,050 --> 00:40:32,410 Here we've got a much simpler model problem, 642 00:40:32,410 --> 00:40:34,660 linear, constant coefficients. 643 00:40:34,660 --> 00:40:40,850 But what do we do? 644 00:40:40,850 --> 00:40:43,410 Can I propose three possibilities here? 645 00:40:43,410 --> 00:40:48,210 And actually they are identical to these three possibilities. 646 00:40:48,210 --> 00:40:50,760 If I just switch over to a first order system. 647 00:40:50,760 --> 00:41:01,180 So possibility one_ Possibility one is that u_(n+1) 648 00:41:01,180 --> 00:41:05,470 and v_(n+1)-- So the u_(n+1) would be, 649 00:41:05,470 --> 00:41:07,820 how do I model that equation? 650 00:41:07,820 --> 00:41:15,480 u_(n+1) is u_n + delta t*v_n. 651 00:41:15,480 --> 00:41:19,840 That would be a natural-- Right? 652 00:41:19,840 --> 00:41:22,410 Let me just pause there, because that's 653 00:41:22,410 --> 00:41:27,820 meant to be the natural forward difference. 654 00:41:27,820 --> 00:41:33,770 So I replaced u' by u_(n+1)-u_n over delta t. 655 00:41:33,770 --> 00:41:38,480 And I replaced v by the value I know. 656 00:41:38,480 --> 00:41:45,010 And do you know whose name is associated with that? 657 00:41:45,010 --> 00:41:49,420 I'm almost going to say his name. 658 00:41:49,420 --> 00:41:52,490 It's just, I replace a differential equation 659 00:41:52,490 --> 00:41:55,530 by a difference equation where each step 660 00:41:55,530 --> 00:41:57,470 I just could figure out what the slope is 661 00:41:57,470 --> 00:42:02,130 and I go along a straight line. 662 00:42:02,130 --> 00:42:05,020 Delta t further along. 663 00:42:05,020 --> 00:42:07,350 Do you know his name? 664 00:42:07,350 --> 00:42:08,970 Euler, Euler, right. 665 00:42:08,970 --> 00:42:10,980 It's Euler's method. 666 00:42:10,980 --> 00:42:14,530 The very first method you would think of. 667 00:42:14,530 --> 00:42:17,400 Right? 668 00:42:17,400 --> 00:42:22,870 So I'm doing the same for v. This 669 00:42:22,870 --> 00:42:27,880 is my position I've reached. 670 00:42:27,880 --> 00:42:29,894 So Euler's method is replace this 671 00:42:29,894 --> 00:42:31,060 by over delta t equals -u_n. 672 00:42:31,060 --> 00:42:38,010 v_(n+1)-v_n over delta t equals -u_n. 673 00:42:38,010 --> 00:42:39,940 So this is Euler's idea. 674 00:42:39,940 --> 00:42:44,880 Predict the new value by a forward difference 675 00:42:44,880 --> 00:42:50,370 starting from where the slope of the line is this old one. 676 00:42:50,370 --> 00:42:55,870 That's the first difference method you would think of. 677 00:42:55,870 --> 00:42:59,350 So now if I multiply up by delta t I have a minus delta t*u_n. 678 00:42:59,350 --> 00:43:09,670 679 00:43:09,670 --> 00:43:14,020 Good time to pay attention. 680 00:43:14,020 --> 00:43:18,870 This is forward Euler. 681 00:43:18,870 --> 00:43:27,340 Forward Euler. 682 00:43:27,340 --> 00:43:31,520 The time step, you follow the derivative, 683 00:43:31,520 --> 00:43:34,800 what the derivative is at the start of the step. 684 00:43:34,800 --> 00:43:36,650 You follow it for a little step. 685 00:43:36,650 --> 00:43:39,290 Ah, let me draw what the thing would do. 686 00:43:39,290 --> 00:43:42,670 Shall I draw what forward Euler will do? 687 00:43:42,670 --> 00:43:43,900 So we're here. 688 00:43:43,900 --> 00:43:46,560 And what's our first step? 689 00:43:46,560 --> 00:43:47,490 Our first step. 690 00:43:47,490 --> 00:43:51,410 So we're starting at v is zero at the start. 691 00:43:51,410 --> 00:43:53,950 So u won't change in one step. 692 00:43:53,950 --> 00:43:58,380 But u is one, so v will go down. 693 00:43:58,380 --> 00:44:04,900 I think the first step will take us there. 694 00:44:04,900 --> 00:44:08,220 That point was (1, 0). 695 00:44:08,220 --> 00:44:13,330 And I think the second step, u came from the zero, 696 00:44:13,330 --> 00:44:15,450 so it'll still be a one. 697 00:44:15,450 --> 00:44:19,780 And v came from a zero, but minus delta. 698 00:44:19,780 --> 00:44:27,840 I think it'll just be 1-delta t. 699 00:44:27,840 --> 00:44:33,320 It's left the circle, of course. 700 00:44:33,320 --> 00:44:42,780 And what do you think happens when I do 1,000 steps? 701 00:44:42,780 --> 00:44:45,920 This is two lines in MATLAB. 702 00:44:45,920 --> 00:44:51,900 Just write those equations for the next u coming 703 00:44:51,900 --> 00:44:57,000 from the previous u starting at (1, 0) and see what happens. 704 00:44:57,000 --> 00:45:00,790 And what do you think? 705 00:45:00,790 --> 00:45:03,060 It's going to sort of go around. 706 00:45:03,060 --> 00:45:05,810 I mean, it's a reasonable-- Euler wasn't dumb. 707 00:45:05,810 --> 00:45:10,750 Anything true here is the fact that Euler was not dumb. 708 00:45:10,750 --> 00:45:13,620 He had a bunch of ideas. 709 00:45:13,620 --> 00:45:16,880 This wasn't his greatest. 710 00:45:16,880 --> 00:45:21,280 But it's the starting point of any, 711 00:45:21,280 --> 00:45:23,560 if you have to code some complicated problem, 712 00:45:23,560 --> 00:45:26,620 start with Euler, forward Euler. 713 00:45:26,620 --> 00:45:28,730 What'll happen? 714 00:45:28,730 --> 00:45:30,010 It'll spiral out. 715 00:45:30,010 --> 00:45:30,720 Exactly. 716 00:45:30,720 --> 00:45:32,800 It'll spiral out. 717 00:45:32,800 --> 00:45:37,070 And if I was an eigenvalue person, 718 00:45:37,070 --> 00:45:44,300 I guess which I probably am, I would look at the, there's 719 00:45:44,300 --> 00:45:48,320 some matrix here that's finding the new u, v from the old u, 720 00:45:48,320 --> 00:45:51,670 v. Maybe we can even find out, write 721 00:45:51,670 --> 00:45:57,110 above what that matrix is. 722 00:45:57,110 --> 00:46:00,120 The new u, v come from the old u, v, 723 00:46:00,120 --> 00:46:02,890 well there is the identity matrix. 724 00:46:02,890 --> 00:46:04,850 Here is a delta t. 725 00:46:04,850 --> 00:46:07,730 And here is our minus delta t. 726 00:46:07,730 --> 00:46:11,780 That would be my matrix. 727 00:46:11,780 --> 00:46:13,930 That's the forward Euler matrix. 728 00:46:13,930 --> 00:46:19,830 The growth matrix for forward Euler is that. 729 00:46:19,830 --> 00:46:24,200 Now what do you think about its eigenvalues before? 730 00:46:24,200 --> 00:46:29,960 Spiral out was the right answer. 731 00:46:29,960 --> 00:46:34,810 If delta t is small it'll stay close to the circle, 732 00:46:34,810 --> 00:46:38,790 but it'll spiral out from it. 733 00:46:38,790 --> 00:46:45,590 So if we were following a planet, it would just be off. 734 00:46:45,590 --> 00:46:48,310 So I can't immediately, well you could almost 735 00:46:48,310 --> 00:46:51,010 see the eigenvalues of this matrix. 736 00:46:51,010 --> 00:46:54,210 What's the determinant of that matrix? 737 00:46:54,210 --> 00:46:55,910 What's the determinant of G? 738 00:46:55,910 --> 00:46:58,510 I'm just asking you to think through. 739 00:46:58,510 --> 00:47:00,310 You see a matrix like this. 740 00:47:00,310 --> 00:47:03,630 You wonder about its eigenvalues so you take the determinant. 741 00:47:03,630 --> 00:47:06,480 And what do you get? 742 00:47:06,480 --> 00:47:10,330 One, something bigger than one or less than one? 743 00:47:10,330 --> 00:47:11,420 Bigger. 744 00:47:11,420 --> 00:47:12,940 So that tells me what? 745 00:47:12,940 --> 00:47:16,600 Since the determinant is the product of lambda_1*lambda_2, 746 00:47:16,600 --> 00:47:20,560 whatever those guys are, at least one of those eigenvalues 747 00:47:20,560 --> 00:47:23,540 is bigger than one. 748 00:47:23,540 --> 00:47:26,120 This has an eigenvalue, actually, 749 00:47:26,120 --> 00:47:31,160 the actual eigenvalues of this happen to be one from 750 00:47:31,160 --> 00:47:36,050 the identity matrix and then this guy is what was 751 00:47:36,050 --> 00:47:41,700 our example of an imaginary eigenvalue, i*delta t. 752 00:47:41,700 --> 00:47:45,330 Bigger than one in absolute value. 753 00:47:45,330 --> 00:47:49,090 It goes out. 754 00:47:49,090 --> 00:47:57,020 So that's forward Euler corresponding to that choice. 755 00:47:57,020 --> 00:48:00,910 Can I change to a second, to Euler's other choice? 756 00:48:00,910 --> 00:48:03,970 And you can guess what its name is. 757 00:48:03,970 --> 00:48:09,460 Instead of forward Euler it's going to be? 758 00:48:09,460 --> 00:48:14,200 Backward Euler. 759 00:48:14,200 --> 00:48:17,670 Euler said, if you don't like it, I've got another one. 760 00:48:17,670 --> 00:48:19,750 And what will happen then? 761 00:48:19,750 --> 00:48:25,490 Backward Euler is going to use, instead of the old value, 762 00:48:25,490 --> 00:48:29,950 it will use the new values here. 763 00:48:29,950 --> 00:48:33,470 So these differences, you see that this is now 764 00:48:33,470 --> 00:48:39,400 a backward difference? 765 00:48:39,400 --> 00:48:41,370 So I'm at time n+1. 766 00:48:41,370 --> 00:48:42,910 I'm at the new time. 767 00:48:42,910 --> 00:48:45,620 And this goes back from that. 768 00:48:45,620 --> 00:48:49,230 So this is at the new time and this is a difference backward. 769 00:48:49,230 --> 00:48:52,020 And what happens now? 770 00:48:52,020 --> 00:48:55,360 Well, we could follow backward Euler. 771 00:48:55,360 --> 00:48:57,190 We could follow its first step. 772 00:48:57,190 --> 00:48:59,710 What would its first step be? 773 00:48:59,710 --> 00:49:00,210 u_n+u_1. 774 00:49:00,210 --> 00:49:07,690 This is-- No, I can't follow that first step so easily. 775 00:49:07,690 --> 00:49:09,890 Help me out by just making a guess. 776 00:49:09,890 --> 00:49:14,260 What do you think backward Euler does? 777 00:49:14,260 --> 00:49:16,590 It spirals in. 778 00:49:16,590 --> 00:49:22,890 Right, the cover of the book has forward Euler, I think, 779 00:49:22,890 --> 00:49:24,950 is on the cover of the textbook. 780 00:49:24,950 --> 00:49:26,460 Spiraling out in the front. 781 00:49:26,460 --> 00:49:31,020 But maybe the back cover also has Euler spiraling in. 782 00:49:31,020 --> 00:49:32,990 So here is backward Euler. 783 00:49:32,990 --> 00:49:36,000 And after I take a bunch of steps 784 00:49:36,000 --> 00:49:40,780 it comes back somewhere there, but it's spiraled in. 785 00:49:40,780 --> 00:49:41,510 No good. 786 00:49:41,510 --> 00:49:47,120 Have we got one minute for the good method? 787 00:49:47,120 --> 00:49:52,550 You're guessing that it's this one? 788 00:49:52,550 --> 00:49:53,780 How does that work? 789 00:49:53,780 --> 00:49:58,760 Actually, it's pretty neat. 790 00:49:58,760 --> 00:50:03,590 So my question is, where do I evaluate these guys? 791 00:50:03,590 --> 00:50:07,950 So this is like forward and backward. 792 00:50:07,950 --> 00:50:14,050 The u equation, so I know u_n and v_n, right? 793 00:50:14,050 --> 00:50:14,800 Everybody with me? 794 00:50:14,800 --> 00:50:17,670 I've got to time in, I know u_n and v_n, 795 00:50:17,670 --> 00:50:22,160 the position and velocity, approximately at point n. 796 00:50:22,160 --> 00:50:23,810 And I want to go n+1. 797 00:50:23,810 --> 00:50:26,950 798 00:50:26,950 --> 00:50:28,860 What I know is v_n. 799 00:50:28,860 --> 00:50:31,360 So that's great. 800 00:50:31,360 --> 00:50:33,190 But what's going to change here? 801 00:50:33,190 --> 00:50:39,370 Now I know u_(n+1) from the first equation. 802 00:50:39,370 --> 00:50:42,520 What shall I do, where shall I evaluate u 803 00:50:42,520 --> 00:50:45,160 in the second equation? 804 00:50:45,160 --> 00:50:46,790 At n+1. 805 00:50:46,790 --> 00:50:47,980 Why not? 806 00:50:47,980 --> 00:50:51,360 I know it already from the first step, 807 00:50:51,360 --> 00:50:54,180 from the forward step with this equation. 808 00:50:54,180 --> 00:50:56,060 I've taken u forward. 809 00:50:56,060 --> 00:51:03,830 So I'll use that forward value of u in the v equation. 810 00:51:03,830 --> 00:51:08,080 So it's forward and backward at the same time. 811 00:51:08,080 --> 00:51:16,700 And the net result if I go back from my system of two 812 00:51:16,700 --> 00:51:20,570 first order equations back to one second order equation, 813 00:51:20,570 --> 00:51:24,240 I'll find the centered guy. 814 00:51:24,240 --> 00:51:34,170 And what do you think happens with that centered difference? 815 00:51:34,170 --> 00:51:39,250 I think MATLAB would have to show it. 816 00:51:39,250 --> 00:51:42,370 And look in Section 2.2 for the picture 817 00:51:42,370 --> 00:51:44,960 that shows the leapfrog method. 818 00:51:44,960 --> 00:51:49,270 So what do you think? 819 00:51:49,270 --> 00:51:57,690 I'm having to depend on my memory now. 820 00:51:57,690 --> 00:52:01,190 It stays almost on the circle. 821 00:52:01,190 --> 00:52:05,840 I think it maybe, it stays very close to the circle. 822 00:52:05,840 --> 00:52:11,650 And comes back almost at the right time, but not exactly. 823 00:52:11,650 --> 00:52:13,690 Because we have an error here. 824 00:52:13,690 --> 00:52:15,950 No, we haven't got the real equation. 825 00:52:15,950 --> 00:52:19,620 We've got a difference equation. 826 00:52:19,620 --> 00:52:23,590 So maybe that's the point to say. 827 00:52:23,590 --> 00:52:25,480 When you start with a differential equation 828 00:52:25,480 --> 00:52:29,890 you've got various choices. 829 00:52:29,890 --> 00:52:32,430 Backward is actually safer. 830 00:52:32,430 --> 00:52:37,600 Probably for a car crash. 831 00:52:37,600 --> 00:52:40,000 No, actually I think for a car crash 832 00:52:40,000 --> 00:52:43,380 they would use forward differences 833 00:52:43,380 --> 00:52:45,930 because they have to take so many. 834 00:52:45,930 --> 00:52:47,090 Let me check on that. 835 00:52:47,090 --> 00:52:54,430 But for our problem, this one, leapfrog is the winner. 836 00:52:54,430 --> 00:52:56,690 Actually, if anybody does computation 837 00:52:56,690 --> 00:52:58,750 in computational chemistry, I mean 838 00:52:58,750 --> 00:53:03,070 that's a subject that uses giant supercomputers to follow 839 00:53:03,070 --> 00:53:07,230 molecular dynamics, to follow what molecules are doing 840 00:53:07,230 --> 00:53:09,770 at high speed, very high speed. 841 00:53:09,770 --> 00:53:13,410 So this, there's a giant number multiplying that u. 842 00:53:13,410 --> 00:53:19,160 And they use leapfrog method. 843 00:53:19,160 --> 00:53:22,040 I'll say a little more Friday if I can 844 00:53:22,040 --> 00:53:26,110 about this general subject, because it's so important.