1 00:00:00,030 --> 00:00:02,400 The following content is provided under a Creative 2 00:00:02,400 --> 00:00:03,770 Commons license. 3 00:00:03,770 --> 00:00:06,020 Your support will help MIT OpenCourseWare 4 00:00:06,020 --> 00:00:10,100 continue to offer high quality educational resources for free. 5 00:00:10,100 --> 00:00:12,670 To make a donation, or to view additional materials 6 00:00:12,670 --> 00:00:16,580 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:16,580 --> 00:00:17,235 at ocw.mit.edu. 8 00:00:26,920 --> 00:00:29,070 All right, OK, let's start. 9 00:00:29,070 --> 00:00:39,450 1690, Numerical Matters. 10 00:00:39,450 --> 00:00:42,330 Local accuracy and global accuracy, 11 00:00:42,330 --> 00:00:48,200 again, this is an distinction between local accuracy 12 00:00:48,200 --> 00:00:50,390 and the global accuracy. 13 00:00:50,390 --> 00:00:52,360 What is the distinction? 14 00:00:52,360 --> 00:00:58,520 What is that we ultimately want in a numerical method? 15 00:00:58,520 --> 00:01:03,930 Do we ultimately want global accuracy or local accuracy? 16 00:01:03,930 --> 00:01:06,600 We ultimately want global accuracy, right? 17 00:01:06,600 --> 00:01:11,330 Local accuracy, actually, I mean if a scheme only has 18 00:01:11,330 --> 00:01:15,820 local accuracy, it's useless. 19 00:01:15,820 --> 00:01:17,480 It is useful only [? if it has ?] 20 00:01:17,480 --> 00:01:18,360 global accuracy. 21 00:01:18,360 --> 00:01:22,990 Global accuracy means the solution using numerical method 22 00:01:22,990 --> 00:01:26,060 actually matches the true solution 23 00:01:26,060 --> 00:01:28,580 as my delta t goes to 0. 24 00:01:28,580 --> 00:01:30,772 So global accuracy is what we want. 25 00:01:33,980 --> 00:01:36,890 But how can we analyze global accuracy? 26 00:01:36,890 --> 00:01:39,620 We can only look at global accuracy 27 00:01:39,620 --> 00:01:42,750 when we of apply the scheme to solve a differential equation. 28 00:01:42,750 --> 00:01:44,620 Right? 29 00:01:44,620 --> 00:01:49,290 Is there a way to show global accuracy without actually 30 00:01:49,290 --> 00:01:51,895 coding it up and solve a particular differential 31 00:01:51,895 --> 00:01:52,395 equation? 32 00:01:58,160 --> 00:02:02,870 Is there a way to show global accuracy without applying 33 00:02:02,870 --> 00:02:06,330 this definition? 34 00:02:06,330 --> 00:02:08,270 AUDIENCE: [INAUDIBLE] 35 00:02:16,030 --> 00:02:17,560 PROFESSOR: OK, so global accuracy 36 00:02:17,560 --> 00:02:24,280 means V at a particular time converges to u at t. 37 00:02:24,280 --> 00:02:26,750 So Vt is the numerical solution. 38 00:02:26,750 --> 00:02:29,740 ut is some true solution I may or may not 39 00:02:29,740 --> 00:02:33,430 know, depending on what equation it is. 40 00:02:33,430 --> 00:02:34,965 So this is global accuracy. 41 00:02:34,965 --> 00:02:36,840 I mean, of course I can check global accuracy 42 00:02:36,840 --> 00:02:39,125 by applying my scheme to a particular differential 43 00:02:39,125 --> 00:02:40,330 equation. 44 00:02:40,330 --> 00:02:44,580 But is there a way I can know if a scheme is globally 45 00:02:44,580 --> 00:02:47,060 accurate or not without [INAUDIBLE] apply? 46 00:02:47,060 --> 00:02:47,831 Yes? 47 00:02:47,831 --> 00:02:50,576 AUDIENCE: [INAUDIBLE] 48 00:02:50,576 --> 00:02:51,200 PROFESSOR: Yes. 49 00:02:51,200 --> 00:02:52,940 That's the answer I'm looking for. 50 00:02:52,940 --> 00:02:57,720 If the scheme is locally accurate, which is also 51 00:02:57,720 --> 00:03:02,470 consistent, and it is 0 stable, then 52 00:03:02,470 --> 00:03:06,260 I know whatever differential equation I applied it to, 53 00:03:06,260 --> 00:03:10,240 I'm going to get global accuracy. 54 00:03:10,240 --> 00:03:11,670 This is a good thing because it is 55 00:03:11,670 --> 00:03:14,570 independent of what differential equation I look at. 56 00:03:17,340 --> 00:03:21,660 If I can show local accuracy, which 57 00:03:21,660 --> 00:03:28,130 doesn't require me to implement anything, I just do what? 58 00:03:28,130 --> 00:03:30,506 How do I show local accuracy? 59 00:03:30,506 --> 00:03:32,160 AUDIENCE: Parallel theory? 60 00:03:32,160 --> 00:03:34,069 PROFESSOR: Parallel theory is right. 61 00:03:34,069 --> 00:03:36,360 You can show local accuracy by applying parallel theory 62 00:03:36,360 --> 00:03:38,130 as analysis. 63 00:03:38,130 --> 00:03:40,480 And can you also show zero stability 64 00:03:40,480 --> 00:03:44,515 without implementing anything? 65 00:03:44,515 --> 00:03:45,390 AUDIENCE: [INAUDIBLE] 66 00:03:49,079 --> 00:03:49,870 PROFESSOR: Exactly. 67 00:03:49,870 --> 00:03:52,180 You can plug in the du dt equal to 0. 68 00:03:52,180 --> 00:03:56,990 So 0 stability is if a scheme can solve this. 69 00:03:56,990 --> 00:03:58,960 Usually, whatever scheme you have, 70 00:03:58,960 --> 00:04:01,600 you're plugging this previous differential equation 71 00:04:01,600 --> 00:04:02,930 into the scheme. 72 00:04:02,930 --> 00:04:06,090 You can analyze this behavior analytically. 73 00:04:06,090 --> 00:04:10,440 You can plug in an exponentially growing solution 74 00:04:10,440 --> 00:04:14,480 to see if that solution is possible. 75 00:04:14,480 --> 00:04:17,209 If an exponentially growing solution is possible, 76 00:04:17,209 --> 00:04:20,965 then the scheme is not zero stable. 77 00:04:20,965 --> 00:04:28,200 If an exponentially growing solution is possible, 78 00:04:28,200 --> 00:04:29,670 then it's not zero stable. 79 00:04:29,670 --> 00:04:32,800 If an exponentially growing solution is not possible, 80 00:04:32,800 --> 00:04:35,480 then the scheme is zero stable. 81 00:04:35,480 --> 00:04:39,320 Now you can show local order of accuracy and zero stability all 82 00:04:39,320 --> 00:04:43,520 without implementing the scheme on any differential equation. 83 00:04:43,520 --> 00:04:46,580 And once you have these tools through the [INAUDIBLE] 84 00:04:46,580 --> 00:04:51,830 equivalence theorem, you know the scheme is globally accurate 85 00:04:51,830 --> 00:04:56,790 when it is applied to any differential equation. 86 00:04:56,790 --> 00:05:00,150 Is it clear, the relationship between these three? 87 00:05:04,150 --> 00:05:07,740 Global accuracy is what we want. 88 00:05:07,740 --> 00:05:10,640 This is what we want. 89 00:05:10,640 --> 00:05:15,632 What we want. 90 00:05:15,632 --> 00:05:19,620 And the zero stability and local accuracy is easy to analyze. 91 00:05:25,750 --> 00:05:30,640 And once we have the two easy to analyze things, we check these, 92 00:05:30,640 --> 00:05:32,777 then we automatically know global accuracy. 93 00:05:36,050 --> 00:05:40,180 So the relationship between these three are this simple. 94 00:05:40,180 --> 00:05:43,310 So when we have these two, that leads to global accuracy. 95 00:05:45,920 --> 00:05:48,300 So we discussed zero stability. 96 00:05:48,300 --> 00:05:53,220 But zero stability is a pretty weak criterion. 97 00:05:53,220 --> 00:05:58,470 So zero stability means it can solve du dt. 98 00:05:58,470 --> 00:06:03,780 Yes, if a scheme is locally accurate and zero stable, 99 00:06:03,780 --> 00:06:06,840 we are going to have global accuracy. 100 00:06:06,840 --> 00:06:11,419 But sometimes, global accuracy may not be enough. 101 00:06:11,419 --> 00:06:13,835 I'm going to show an example of why global accuracy is not 102 00:06:13,835 --> 00:06:15,140 enough. 103 00:06:15,140 --> 00:06:19,365 So global accuracy only says that [INAUDIBLE] equal to zero. 104 00:06:19,365 --> 00:06:24,650 [INAUDIBLE] solution [INAUDIBLE] analytical [INAUDIBLE], right? 105 00:06:24,650 --> 00:06:30,520 It doesn't say anything on if my [INAUDIBLE] is finite, 106 00:06:30,520 --> 00:06:32,660 how big the error is. 107 00:06:35,650 --> 00:06:38,985 It also doesn't say how [INAUDIBLE] my solution is. 108 00:06:42,650 --> 00:06:48,260 And it turns out we can get [INAUDIBLE] solutions 109 00:06:48,260 --> 00:06:53,070 for finite delta t even if a scheme is local order 110 00:06:53,070 --> 00:06:56,569 of accuracy and zero stable. 111 00:06:56,569 --> 00:06:59,070 I'm going to show you such an example. 112 00:06:59,070 --> 00:07:05,870 The example is using a second order accurate scheme 113 00:07:05,870 --> 00:07:07,360 and also zero stable. 114 00:07:07,360 --> 00:07:09,820 Can you guys think of a zero stable scheme 115 00:07:09,820 --> 00:07:11,730 that is second order accurate? 116 00:07:16,480 --> 00:07:19,785 What scheme have you learned that is second [? order ?] 117 00:07:19,785 --> 00:07:20,410 [? accurate? ?] 118 00:07:20,410 --> 00:07:21,210 AUDIENCE: Midpoint. 119 00:07:21,210 --> 00:07:21,480 PROFESSOR: Midpoint. 120 00:07:21,480 --> 00:07:21,980 Exactly. 121 00:07:21,980 --> 00:07:23,520 Midpoint is locally accurate. 122 00:07:23,520 --> 00:07:25,060 It's zero stable. 123 00:07:25,060 --> 00:07:29,480 And in something we implemented last lecture, right? 124 00:07:29,480 --> 00:07:33,760 So let me go back to my Dropbox. 125 00:07:33,760 --> 00:07:34,260 [INAUDIBLE] 126 00:07:42,260 --> 00:07:44,283 Wait, where is my shared folder? 127 00:07:49,706 --> 00:07:57,360 [INAUDIBLE] up there, but, like-- OK, it's over here. 128 00:08:01,240 --> 00:08:02,595 OK. 129 00:08:02,595 --> 00:08:09,040 I would ask you, who has completed these implementation 130 00:08:09,040 --> 00:08:12,290 we started last class? 131 00:08:12,290 --> 00:08:14,820 Of course [INAUDIBLE] here I have finished. 132 00:08:14,820 --> 00:08:16,573 Who else did it? 133 00:08:16,573 --> 00:08:18,417 Can you raise your-- 134 00:08:18,417 --> 00:08:19,800 AUDIENCE: [INAUDIBLE] 135 00:08:19,800 --> 00:08:22,760 PROFESSOR: No, not including [INAUDIBLE]. 136 00:08:22,760 --> 00:08:23,480 Great, great. 137 00:08:23,480 --> 00:08:27,760 So we have a bunch of people who did this. 138 00:08:27,760 --> 00:08:34,490 Anybody willing to try their code here? 139 00:08:34,490 --> 00:08:34,990 No? 140 00:08:38,420 --> 00:08:41,074 AUDIENCE: [INAUDIBLE] 141 00:08:41,074 --> 00:08:41,990 PROFESSOR: [INAUDIBLE] 142 00:08:41,990 --> 00:08:43,375 AUDIENCE: The first two. 143 00:08:43,375 --> 00:08:44,458 PROFESSOR: The first two.. 144 00:08:44,458 --> 00:08:46,250 All right. 145 00:08:46,250 --> 00:08:52,790 So I'm going to copy your code into today's folder. 146 00:08:52,790 --> 00:08:54,720 And which one should I run? 147 00:08:54,720 --> 00:08:56,001 AUDIENCE: [INAUDIBLE] 148 00:08:56,001 --> 00:08:57,900 PROFESSOR: [INAUDIBLE], OK. 149 00:08:57,900 --> 00:08:58,400 Thank you. 150 00:09:08,330 --> 00:09:09,460 Right. 151 00:09:09,460 --> 00:09:17,610 So I see you did [INAUDIBLE] and midpoint. 152 00:09:17,610 --> 00:09:18,880 OK, you are also doing this. 153 00:09:18,880 --> 00:09:25,430 So I'm just going to use-- I see you did this double percentage 154 00:09:25,430 --> 00:09:25,930 thing. 155 00:09:25,930 --> 00:09:28,800 Does everybody know how to use that? 156 00:09:28,800 --> 00:09:31,300 Yeah, so basically, [INAUDIBLE] according to sections. 157 00:09:31,300 --> 00:09:34,014 So I think it's Control-Enter, right? 158 00:09:34,014 --> 00:09:36,820 To just around these sections? 159 00:09:36,820 --> 00:09:38,480 I think it's already done. 160 00:09:38,480 --> 00:09:42,910 And I can run midpoint. 161 00:09:42,910 --> 00:09:45,660 [INAUDIBLE] 162 00:09:45,660 --> 00:09:48,500 That's nice. 163 00:09:48,500 --> 00:09:51,200 What if I change the delta t to 0.5? 164 00:09:54,400 --> 00:09:56,830 OK, what if I change delta t to 0.5, 165 00:09:56,830 --> 00:09:59,790 and I'm going to close all in the beginning of this so that, 166 00:09:59,790 --> 00:10:03,240 like, I'm going to close my [INAUDIBLE]. 167 00:10:03,240 --> 00:10:06,480 I'm going to run it again. 168 00:10:06,480 --> 00:10:06,990 I get this. 169 00:10:16,420 --> 00:10:18,620 And this doesn't actually defeat the purpose 170 00:10:18,620 --> 00:10:23,330 of the analysis of the scheme being globally accurate. 171 00:10:23,330 --> 00:10:25,240 The scheme is still globally accurate 172 00:10:25,240 --> 00:10:28,370 because, as I decrease my delta t, 173 00:10:28,370 --> 00:10:32,510 as I make delta t equal to 0.3, for example, 174 00:10:32,510 --> 00:10:34,280 the oscillation gets smaller. 175 00:10:34,280 --> 00:10:35,770 My solution gets better. 176 00:10:35,770 --> 00:10:39,954 If I decrease to 0.2, the solution gets still better. 177 00:10:39,954 --> 00:10:43,150 [INAUDIBLE] it gets better and better. 178 00:10:43,150 --> 00:10:49,214 And when I decrease it to 0.1, it's almost invisible. 179 00:10:49,214 --> 00:10:50,380 But I'm going to assure you. 180 00:10:50,380 --> 00:10:53,213 If I let these things drop further, 181 00:10:53,213 --> 00:10:55,080 the oscillation is going to show up. 182 00:10:55,080 --> 00:10:56,756 You want to try? 183 00:10:56,756 --> 00:10:59,060 To try, OK? 184 00:10:59,060 --> 00:11:02,800 p is equal to 100, let's see. 185 00:11:02,800 --> 00:11:06,636 If p is equal to 100, oh, you did the [INAUDIBLE] thing. 186 00:11:06,636 --> 00:11:08,260 I'm going to remove the [INAUDIBLE] him 187 00:11:08,260 --> 00:11:09,675 and do axis equal. 188 00:11:14,640 --> 00:11:16,770 That's too much. 189 00:11:16,770 --> 00:11:20,757 [LAUGHTER] 190 00:11:20,757 --> 00:11:23,670 p is equal to 50. 191 00:11:23,670 --> 00:11:24,170 What? 192 00:11:24,170 --> 00:11:24,670 OK. 193 00:11:29,090 --> 00:11:30,072 Did I change anything? 194 00:11:43,860 --> 00:11:46,620 Why do I get this? 195 00:11:46,620 --> 00:11:48,120 Do I need to do this again? 196 00:11:48,120 --> 00:11:48,620 Or not? 197 00:11:51,530 --> 00:11:53,252 Why do I get a-- 198 00:11:53,252 --> 00:11:55,216 AUDIENCE: [INAUDIBLE] 199 00:12:00,125 --> 00:12:01,000 PROFESSOR: Variables. 200 00:12:04,530 --> 00:12:06,340 The first one, OK? 201 00:12:06,340 --> 00:12:08,900 I ran it, and then we're on the next point. 202 00:12:08,900 --> 00:12:10,570 Oh, there it is. 203 00:12:10,570 --> 00:12:14,660 So let me go back to my p equal to 50. 204 00:12:14,660 --> 00:12:19,600 You see what I get over here? 205 00:12:19,600 --> 00:12:21,410 I don't get a solution that is smooth. 206 00:12:21,410 --> 00:12:26,380 I get a solution that-- [INAUDIBLE]. 207 00:12:36,505 --> 00:12:41,220 So what happens-- still, it doesn't defeat the purpose 208 00:12:41,220 --> 00:12:42,670 of being globally accurate. 209 00:12:42,670 --> 00:12:46,590 If I make delta t equal to 0.05, this oscillation 210 00:12:46,590 --> 00:12:48,220 becomes smaller. 211 00:12:48,220 --> 00:12:52,650 We can still see it, but it becomes smaller. 212 00:12:52,650 --> 00:12:58,540 But when I increase t to be 100 again, 213 00:12:58,540 --> 00:13:00,376 this is going to show up again. 214 00:13:00,376 --> 00:13:03,050 I mean, I see something is wrong. 215 00:13:06,751 --> 00:13:07,250 OK. 216 00:13:07,250 --> 00:13:09,540 So I'll do that later. 217 00:13:09,540 --> 00:13:12,900 But the point is clear, right, although the skin 218 00:13:12,900 --> 00:13:16,830 is zero stable, it is second order accurate, 219 00:13:16,830 --> 00:13:19,505 the midpoint scheme. 220 00:13:19,505 --> 00:13:24,746 But it doesn't really give the desired behavior. 221 00:13:24,746 --> 00:13:27,880 It's even worse than the forward Euler which is only first order 222 00:13:27,880 --> 00:13:29,340 accurate. 223 00:13:29,340 --> 00:13:30,930 If you look at the forward Euler, 224 00:13:30,930 --> 00:13:34,985 with a delta t of 0.5, which shows horrible behavior 225 00:13:34,985 --> 00:13:36,400 for midpoints, right? 226 00:13:39,725 --> 00:13:41,150 I get an error somewhere. 227 00:13:41,150 --> 00:13:46,900 Oh, I need to run this first, and run this. 228 00:13:46,900 --> 00:13:50,550 So yeah, forward Euler works fine with a delta t 229 00:13:50,550 --> 00:13:53,340 equal to 0.5. 230 00:13:53,340 --> 00:13:57,130 So in this case, forward Euler actually 231 00:13:57,130 --> 00:13:59,640 works better than midpoint, even though midpoint is 232 00:13:59,640 --> 00:14:03,220 a second order accurate scheme. 233 00:14:06,240 --> 00:14:08,360 So why is this the case? 234 00:14:08,360 --> 00:14:12,642 Both schemes are zero stable. 235 00:14:12,642 --> 00:14:15,855 Midpoint is more accurate, supposedly more accurate 236 00:14:15,855 --> 00:14:17,890 than forward Euler. 237 00:14:17,890 --> 00:14:21,120 But applied to this specific equation, 238 00:14:21,120 --> 00:14:23,720 unlike the equation we saw last week, 239 00:14:23,720 --> 00:14:26,950 the pendulum equation-- on the pendulum equation, midpoint 240 00:14:26,950 --> 00:14:29,405 actually works much, much better than forward 241 00:14:29,405 --> 00:14:31,340 Euler for a large [INAUDIBLE]. 242 00:14:31,340 --> 00:14:32,980 Here, a forward Euler works better 243 00:14:32,980 --> 00:14:36,450 than midpoint or [INAUDIBLE]. 244 00:14:36,450 --> 00:14:39,960 The reason is linked with eigenvalue stability. 245 00:14:43,740 --> 00:14:50,380 It turns out that the particular case, we are looking at, 246 00:14:50,380 --> 00:14:52,420 for which forward Euler is actually 247 00:14:52,420 --> 00:14:54,810 eigenvalue stable, and the midpoint 248 00:14:54,810 --> 00:14:56,950 is not eigenvalue stable. 249 00:14:56,950 --> 00:14:59,780 So eigenvalue stability is a requirement 250 00:14:59,780 --> 00:15:04,500 that is more strict, more stringent, than 0 stability. 251 00:15:04,500 --> 00:15:06,600 Although midpoint is zero stable , 252 00:15:06,600 --> 00:15:09,660 it is not eigenvalue stable for that particular equation. 253 00:15:12,250 --> 00:15:16,700 OK, any questions before we move on? 254 00:15:16,700 --> 00:15:18,680 AUDIENCE: [INAUDIBLE] 255 00:15:23,879 --> 00:15:24,670 PROFESSOR: Exactly. 256 00:15:24,670 --> 00:15:25,730 Good question. 257 00:15:25,730 --> 00:15:30,940 So zero stability is per scheme. 258 00:15:30,940 --> 00:15:35,154 A scheme is either zero stable or not. 259 00:15:35,154 --> 00:15:37,070 It's independent of the differential equation, 260 00:15:37,070 --> 00:15:39,510 because it just tells you, can scheme solve 261 00:15:39,510 --> 00:15:41,730 this previous differential equation or not. 262 00:15:41,730 --> 00:15:43,870 Eigenvalue stability, on the other hand, 263 00:15:43,870 --> 00:15:47,530 depends not only on the scheme, but also on the equation. 264 00:15:47,530 --> 00:15:50,750 In the simplest case, eigenvalue stability looks at, 265 00:15:50,750 --> 00:15:56,700 are you able to solve this equation? 266 00:15:56,700 --> 00:16:01,649 So you can see zero stability is like a standard case 267 00:16:01,649 --> 00:16:06,470 of eigenvalue stability, where lambda is equal to zero. 268 00:16:06,470 --> 00:16:10,370 So if a scheme is eigenvalue stable 269 00:16:10,370 --> 00:16:14,160 for lambda equal to zero, then it is zero stable. 270 00:16:14,160 --> 00:16:16,740 But a scheme being zero stable doesn't 271 00:16:16,740 --> 00:16:19,804 mean it is always eigenvalue stable for all differential 272 00:16:19,804 --> 00:16:22,170 equations like that. 273 00:16:22,170 --> 00:16:26,370 OK, so let's start discussing eigenvalue stability. 274 00:16:26,370 --> 00:16:27,820 And at the end of the lecture, I'm 275 00:16:27,820 --> 00:16:31,990 also going to start talking about implicit schemes 276 00:16:31,990 --> 00:16:33,770 and the Newton Raphson iteration. 277 00:16:33,770 --> 00:16:35,130 All right. 278 00:16:35,130 --> 00:16:37,000 So eigenvalue stability analysis, 279 00:16:37,000 --> 00:16:40,260 the first thing I want to show you is this link. 280 00:16:40,260 --> 00:16:43,110 If you go to this link, which I already opened, 281 00:16:43,110 --> 00:16:47,250 I think, you're going to get to the website called 282 00:16:47,250 --> 00:16:49,400 mathlets.org. 283 00:16:49,400 --> 00:16:53,050 And it hosts a bunch of what they call Mathlets. 284 00:16:53,050 --> 00:16:54,890 They are basically Java applets that 285 00:16:54,890 --> 00:16:59,360 allows you to visualize these various things. 286 00:16:59,360 --> 00:17:02,670 And if you click on it, it is going to open a window. 287 00:17:02,670 --> 00:17:05,800 You need a statue like Java security or something 288 00:17:05,800 --> 00:17:09,369 like add exception to mathlets.org. 289 00:17:09,369 --> 00:17:13,089 Otherwise, your browser may actually block the thing. 290 00:17:13,089 --> 00:17:15,785 But once you have it-- let me make it full screen. 291 00:17:19,750 --> 00:17:21,660 OK. 292 00:17:21,660 --> 00:17:23,060 Right. 293 00:17:23,060 --> 00:17:29,520 So what it shows you is for what lambda-- remember, 294 00:17:29,520 --> 00:17:34,830 we are talking about eigenvalue stability-- 295 00:17:34,830 --> 00:17:39,080 is a scheme stable or not for this equation. 296 00:17:39,080 --> 00:17:41,760 So we have a lambda here. 297 00:17:41,760 --> 00:17:43,920 In the mathlet, a lambda can only 298 00:17:43,920 --> 00:17:47,790 be real values, but complex values. 299 00:17:47,790 --> 00:17:52,820 So this is the space of our lambda times delta t. 300 00:17:56,500 --> 00:18:00,500 We can think of a point here is 1, 0. 301 00:18:00,500 --> 00:18:04,540 That means lambda times delta t equals to 1. 302 00:18:04,540 --> 00:18:09,092 So, for example, at this point, this lambda is equal to 10. 303 00:18:09,092 --> 00:18:11,563 Delta t is equal to 0.1. 304 00:18:11,563 --> 00:18:12,830 Then you're at this point. 305 00:18:12,830 --> 00:18:16,674 If lambda is equal to minus 1, [INAUDIBLE]. 306 00:18:20,530 --> 00:18:25,490 The blue regions here shows you that for what 307 00:18:25,490 --> 00:18:28,180 values of lambda, for what combinations 308 00:18:28,180 --> 00:18:30,920 of lambda and delta t-- actually, 309 00:18:30,920 --> 00:18:33,390 it only includes the lambda. 310 00:18:33,390 --> 00:18:37,824 What lambda times delta t is, for a particular scheme, 311 00:18:37,824 --> 00:18:38,995 eigenvalue stable. 312 00:18:38,995 --> 00:18:41,940 So here is the forward Euler. 313 00:18:41,940 --> 00:18:45,740 For forward Euler, the scheme is stable 314 00:18:45,740 --> 00:18:48,130 only if lambda [INAUDIBLE] times delta t 315 00:18:48,130 --> 00:18:52,158 was using this very small circle. 316 00:18:52,158 --> 00:18:55,860 OK, what does this mean? 317 00:18:55,860 --> 00:19:02,456 This means that if you have a lambda greater than zero, 318 00:19:02,456 --> 00:19:06,680 would forward Euler ever be stable? 319 00:19:06,680 --> 00:19:09,200 No. 320 00:19:09,200 --> 00:19:14,060 Actually, I would expect, if lambda is greater than zero, 321 00:19:14,060 --> 00:19:18,540 even the analytic solution of the PDE is unstable. 322 00:19:18,540 --> 00:19:19,830 Why? 323 00:19:19,830 --> 00:19:22,010 What is is the analytic solution for TDE? 324 00:19:22,010 --> 00:19:23,790 AUDIENCE: [INAUDIBLE] 325 00:19:23,790 --> 00:19:26,160 PROFESSOR: e to the lambda t, right? 326 00:19:26,160 --> 00:19:28,162 Each of the lambda t is the analytic solution 327 00:19:28,162 --> 00:19:31,210 of [INAUDIBLE] unstable by itself. 328 00:19:31,210 --> 00:19:35,490 So actually, not the only real one, but also 329 00:19:35,490 --> 00:19:40,440 the whole [INAUDIBLE] the analytical OD is unstable. 330 00:19:43,550 --> 00:19:50,190 Because if the lambda is here, then the lambda is 1 plus i, 331 00:19:50,190 --> 00:19:52,400 how does the solution look like? 332 00:19:55,220 --> 00:19:58,490 It's an oscillatory growing solution, right? 333 00:19:58,490 --> 00:20:01,519 The imaginary part determines the frequency 334 00:20:01,519 --> 00:20:02,310 of the oscillation. 335 00:20:02,310 --> 00:20:05,570 But real part determines the rate of growth. 336 00:20:05,570 --> 00:20:08,250 As long as the real part is greater than zero, 337 00:20:08,250 --> 00:20:10,540 it's a growing oscillatory solution. 338 00:20:13,210 --> 00:20:17,160 So that means, for the whole [INAUDIBLE] 339 00:20:17,160 --> 00:20:20,300 of the complex [INAUDIBLE], the analytical solution [INAUDIBLE] 340 00:20:20,300 --> 00:20:22,220 is unstable. 341 00:20:22,220 --> 00:20:24,740 So you shouldn't really expect a numerical solution 342 00:20:24,740 --> 00:20:26,822 to make it stable. 343 00:20:26,822 --> 00:20:28,197 I mean, you're going to see some, 344 00:20:28,197 --> 00:20:30,697 the numerical scheme actually does make some of them stable, 345 00:20:30,697 --> 00:20:34,340 but you shouldn't expect it. 346 00:20:34,340 --> 00:20:39,910 What is more intriguing is that, even on the [INAUDIBLE] 347 00:20:39,910 --> 00:20:43,840 for which the analytical behavior of the ODE 348 00:20:43,840 --> 00:20:48,820 is either just a monotonic detail [INAUDIBLE] 349 00:20:48,820 --> 00:20:55,720 on the real axis into something negative times t. 350 00:20:55,720 --> 00:21:01,830 So is du dt equal to negative lambda times u. 351 00:21:01,830 --> 00:21:06,093 The solution is u equal to u to the negative [INAUDIBLE] times 352 00:21:06,093 --> 00:21:06,814 t. 353 00:21:06,814 --> 00:21:07,980 So you get a monotonic case. 354 00:21:07,980 --> 00:21:10,712 If you are over here, we'll have a negative real time, 355 00:21:10,712 --> 00:21:12,530 and a non-zero imaginary [INAUDIBLE], 356 00:21:12,530 --> 00:21:17,900 then you have an oscillating and decaying solution. 357 00:21:17,900 --> 00:21:20,730 So you would also expect it to be stable. 358 00:21:20,730 --> 00:21:23,160 But forward Euler, actually, is only 359 00:21:23,160 --> 00:21:25,794 stable within this region [INAUDIBLE] 360 00:21:25,794 --> 00:21:28,228 lamba delta [INAUDIBLE] over here, it's unstable. 361 00:21:34,410 --> 00:21:38,190 OK, so that is interesting. 362 00:21:38,190 --> 00:21:41,110 I'm just going to do a very brief analysis of showing 363 00:21:41,110 --> 00:21:43,110 why that is the case. 364 00:21:43,110 --> 00:21:48,720 Forward Euler, V of n plus 1 minus V n over delta t 365 00:21:48,720 --> 00:21:53,940 applied to half of V n, which, in this case, is lambda times 366 00:21:53,940 --> 00:21:54,930 V n. 367 00:21:59,330 --> 00:22:04,920 So let's move all the knowns to the right hand side. 368 00:22:04,920 --> 00:22:07,730 So this term is known, and this term is known. 369 00:22:07,730 --> 00:22:09,850 So move this to the right hand side. 370 00:22:09,850 --> 00:22:14,410 We have V n plus 1 over delta t is 371 00:22:14,410 --> 00:22:19,965 equal to V n over the delta t plus lambda times v n. 372 00:22:19,965 --> 00:22:27,900 And the [INAUDIBLE] is, if we [INAUDIBLE], V n plus 1 373 00:22:27,900 --> 00:22:33,936 would be equal to 1 plus delta t lambda times v n. 374 00:22:38,330 --> 00:22:43,540 We can easily see if lambda is greater than 0, 375 00:22:43,540 --> 00:22:45,550 we have a growing solution. 376 00:22:45,550 --> 00:22:49,592 If lambda is greater than zero, this term is greater than 1, 377 00:22:49,592 --> 00:22:51,410 we grow. 378 00:22:51,410 --> 00:22:54,710 What if lambda delta t is less than minus 2? 379 00:23:02,330 --> 00:23:06,080 We get an oscillatory growing solution 380 00:23:06,080 --> 00:23:10,530 because 1 plus delta t lambda would be less than minus 1. 381 00:23:10,530 --> 00:23:14,280 And the next iteration I'm going to get 382 00:23:14,280 --> 00:23:17,780 a solution of the opposite sign, but larger than what 383 00:23:17,780 --> 00:23:19,790 it is at the n times f. 384 00:23:19,790 --> 00:23:23,820 That is why forward Euler is unstable 385 00:23:23,820 --> 00:23:27,590 when we have a lambda delta t less than minus 2. 386 00:23:30,180 --> 00:23:34,462 Same thing happens when lambda is imaginary 387 00:23:34,462 --> 00:23:42,870 and 1 plus delta t lambda has a modulus of greater than 1, 388 00:23:42,870 --> 00:23:44,902 that means we are [INAUDIBLE]. 389 00:23:48,180 --> 00:23:51,830 So that's how you do eigenvalue stability analysis. 390 00:23:51,830 --> 00:23:57,769 You plug in f of u for the lambda u 391 00:23:57,769 --> 00:23:59,200 into the differential equation. 392 00:23:59,200 --> 00:24:02,446 You collect all the terms that is [INAUDIBLE]. 393 00:24:06,910 --> 00:24:11,130 And in general, you plug in the solution that is exponentially 394 00:24:11,130 --> 00:24:17,920 growing to see if the script scheme allows an exponentially 395 00:24:17,920 --> 00:24:20,780 growing solution. 396 00:24:20,780 --> 00:24:25,836 That is how you would analyze eigenvalue stability, 397 00:24:25,836 --> 00:24:30,980 similar to how you would analyze zero stability. 398 00:24:30,980 --> 00:24:32,343 Any questions? 399 00:24:32,343 --> 00:24:33,218 AUDIENCE: [INAUDIBLE] 400 00:24:37,700 --> 00:24:39,824 PROFESSOR: Yeah, the absolute value of that one 401 00:24:39,824 --> 00:24:44,180 has to be less than or equal to 1. 402 00:24:44,180 --> 00:24:45,148 Yes. 403 00:24:45,148 --> 00:24:46,116 Yep? 404 00:24:46,116 --> 00:24:51,045 AUDIENCE: So, when you said that the [INAUDIBLE] has to be 405 00:24:51,045 --> 00:24:54,884 less than minus 2, [INAUDIBLE]? 406 00:24:54,884 --> 00:24:55,800 PROFESSOR: [INAUDIBLE] 407 00:24:58,689 --> 00:24:59,230 AUDIENCE: OK. 408 00:24:59,230 --> 00:25:00,188 Yeah. 409 00:25:00,188 --> 00:25:00,688 [INAUDIBLE] 410 00:25:05,742 --> 00:25:06,950 PROFESSOR: OK, good question. 411 00:25:06,950 --> 00:25:08,324 When you are implementing forward 412 00:25:08,324 --> 00:25:11,165 Euler on the real thing, how do you know [INAUDIBLE]? 413 00:25:14,890 --> 00:25:18,180 It's a good question. 414 00:25:18,180 --> 00:25:24,130 So most of the time, you can analyze the eigenvalues-- 415 00:25:24,130 --> 00:25:26,010 let me back up. 416 00:25:26,010 --> 00:25:31,090 Let me say, if you look at a scalar differential equation, 417 00:25:31,090 --> 00:25:33,835 if you look at, like, just one single differential 418 00:25:33,835 --> 00:25:36,260 equation, not a [? coupled ?] system of differential 419 00:25:36,260 --> 00:25:40,050 equations, even if the equation is non-linear, 420 00:25:40,050 --> 00:25:42,480 you can usually linearize the differential equation 421 00:25:42,480 --> 00:25:46,595 and look at what lambda is for linearized differential 422 00:25:46,595 --> 00:25:48,340 equation. 423 00:25:48,340 --> 00:25:52,840 And the key is not to manipulate lambda, but ensure 424 00:25:52,840 --> 00:25:55,334 that delta t is small enough. 425 00:25:58,000 --> 00:25:59,890 So let's look at here. 426 00:25:59,890 --> 00:26:02,770 Imagine [INAUDIBLE] lambda delta t. 427 00:26:02,770 --> 00:26:06,790 But imagine your lambda is taken over here. 428 00:26:06,790 --> 00:26:09,620 If your lambda is, let's say, minus [INAUDIBLE]. 429 00:26:13,160 --> 00:26:16,500 Can forward Euler be stable? 430 00:26:16,500 --> 00:26:17,000 No? 431 00:26:20,218 --> 00:26:21,630 AUDIENCE: [INAUDIBLE] 432 00:26:21,630 --> 00:26:25,473 PROFESSOR: If my lambda is here, can forward Euler be stable? 433 00:26:25,473 --> 00:26:26,348 AUDIENCE: [INAUDIBLE] 434 00:26:28,920 --> 00:26:30,900 PROFESSOR: We still have delta t, right? 435 00:26:33,425 --> 00:26:37,720 If lambda is here, what is to make delta t with a 0.1? 436 00:26:37,720 --> 00:26:41,280 Then lambda has delta t which [INAUDIBLE] way over to here, 437 00:26:41,280 --> 00:26:44,180 into the stability region. 438 00:26:44,180 --> 00:26:46,870 And we are fine, right? 439 00:26:46,870 --> 00:26:52,935 OK, what if lambda is minus 500 plus 1,000 times i. 440 00:26:52,935 --> 00:26:53,810 AUDIENCE: [INAUDIBLE] 441 00:26:57,140 --> 00:27:03,210 PROFESSOR: Yeah, even if lambda is minus 500 [INAUDIBLE] 442 00:27:03,210 --> 00:27:07,180 to make the delta t equal to 0.0001, 443 00:27:07,180 --> 00:27:09,136 you're going to be fine. 444 00:27:09,136 --> 00:27:12,307 You're going to shrink your eigenvalues times delta 445 00:27:12,307 --> 00:27:12,920 t into here. 446 00:27:12,920 --> 00:27:13,586 And you're fine. 447 00:27:16,010 --> 00:27:19,370 OK, what pieces are not fine? 448 00:27:19,370 --> 00:27:21,800 What are the cases where, no matter how small 449 00:27:21,800 --> 00:27:24,980 you make the delta t, you're going to be unstable? 450 00:27:24,980 --> 00:27:27,930 AUDIENCE: [INAUDIBLE] 451 00:27:27,930 --> 00:27:32,035 PROFESSOR: Right, if lambda has a positive real cost, 452 00:27:32,035 --> 00:27:34,809 if lambda is always here, and no matter how small you shrink it, 453 00:27:34,809 --> 00:27:36,683 you get a small delta t-- because delta t has 454 00:27:36,683 --> 00:27:38,734 to be real, right? 455 00:27:38,734 --> 00:27:39,900 The constant has to be real. 456 00:27:39,900 --> 00:27:41,525 You're going to shrink it to over here, 457 00:27:41,525 --> 00:27:43,840 but it's still unstable, right? 458 00:27:43,840 --> 00:27:47,825 OK, what are the cases where forward Euler is not working? 459 00:27:47,825 --> 00:27:48,700 AUDIENCE: [INAUDIBLE] 460 00:27:51,490 --> 00:27:53,250 PROFESSOR: If it's just an oscillation, 461 00:27:53,250 --> 00:28:00,910 if the eigenvalue lambda is just a dual imaginary value, 462 00:28:00,910 --> 00:28:03,620 it's a non-decaying oscillation. 463 00:28:03,620 --> 00:28:08,540 So if the analytical solution is a non-decaying oscillation, 464 00:28:08,540 --> 00:28:16,040 just like what we had on [INAUDIBLE], like the pendulum, 465 00:28:16,040 --> 00:28:19,155 if we have a pendulum that has no density, 466 00:28:19,155 --> 00:28:22,740 forward Euler would never be eigenvalue stable. 467 00:28:22,740 --> 00:28:24,680 And that's what we saw, right? 468 00:28:24,680 --> 00:28:27,650 I mean, even when we made delta t to be small, 469 00:28:27,650 --> 00:28:28,910 it's still mildly growing. 470 00:28:33,040 --> 00:28:35,010 So yes, forward Euler will work if you 471 00:28:35,010 --> 00:28:37,160 could have a positive real eigenvalue, 472 00:28:37,160 --> 00:28:39,630 or you could have a zero real eigenvalue. 473 00:28:39,630 --> 00:28:42,450 Otherwise, you can always shrink your delta t 474 00:28:42,450 --> 00:28:45,140 so that the scheme is stable. 475 00:28:45,140 --> 00:28:47,050 Let's look at another scheme, midpoint. 476 00:28:49,650 --> 00:28:51,590 OK, what happens on midpoint? 477 00:28:51,590 --> 00:28:53,735 What is the stability region of midpoint? 478 00:28:58,970 --> 00:29:03,724 It lies exactly on the imaginary axis from [INAUDIBLE]. 479 00:29:07,660 --> 00:29:12,960 So the case we have to analyzed saying two oscillations would 480 00:29:12,960 --> 00:29:15,000 never work for forward Euler, would never 481 00:29:15,000 --> 00:29:17,660 be stable for forward Euler, it works 482 00:29:17,660 --> 00:29:19,315 perfectly fine for midpoint. 483 00:29:21,860 --> 00:29:24,200 That's why, when we did the pendulum case, 484 00:29:24,200 --> 00:29:26,440 midpoint worked so well. 485 00:29:26,440 --> 00:29:30,340 It was, like, amazingly better than forward Euler. 486 00:29:30,340 --> 00:29:36,420 But when we applied to this case, forward 487 00:29:36,420 --> 00:29:40,280 Euler works better because-- try to guess 488 00:29:40,280 --> 00:29:49,780 where the eigenvalues are for the case we had on [INAUDIBLE]. 489 00:29:49,780 --> 00:29:51,650 Anybody wants to take a guess of what 490 00:29:51,650 --> 00:29:54,080 lambda is for that problem? 491 00:30:05,100 --> 00:30:07,467 Something with a very small imaginary component? 492 00:30:07,467 --> 00:30:08,342 AUDIENCE: [INAUDIBLE] 493 00:30:13,830 --> 00:30:18,777 PROFESSOR: [INAUDIBLE] means you have negative real part, right? 494 00:30:18,777 --> 00:30:19,679 AUDIENCE: Yeah. 495 00:30:19,679 --> 00:30:20,178 [INAUDIBLE] 496 00:30:23,914 --> 00:30:26,640 PROFESSOR: If you look midpoint, as long 497 00:30:26,640 --> 00:30:33,620 as the eigenvalue lambda has a non-zero [INAUDIBLE], 498 00:30:33,620 --> 00:30:38,130 then it wouldn't be stable, no matter how small you make delta 499 00:30:38,130 --> 00:30:41,100 t-- I mean, if the eigenvalue is here, 500 00:30:41,100 --> 00:30:46,110 over here, no matter how small you make delta t [INAUDIBLE] 501 00:30:46,110 --> 00:30:47,670 was the origin. 502 00:30:47,670 --> 00:30:49,306 But no matter how much you shrink it, 503 00:30:49,306 --> 00:30:54,070 you will never be exactly on the imaginary axis 504 00:30:54,070 --> 00:30:56,500 between [INAUDIBLE], right? 505 00:30:56,500 --> 00:31:04,055 So as long as the solution is not pure oscillation, 506 00:31:04,055 --> 00:31:07,430 midpoint wouldn't work. 507 00:31:07,430 --> 00:31:09,070 So forward Euler and midpoint are 508 00:31:09,070 --> 00:31:13,700 like two schemes that have complimentary values, 509 00:31:13,700 --> 00:31:15,133 but they never overlap. 510 00:31:17,710 --> 00:31:20,470 A question would either work for forward Euler, 511 00:31:20,470 --> 00:31:23,920 or it'll work for midpoint with a small enough time stamp. 512 00:31:27,970 --> 00:31:32,700 If the lambda is exactly on the imaginary axis, 513 00:31:32,700 --> 00:31:37,146 with a small enough delta t, you can make midpoint work. 514 00:31:37,146 --> 00:31:43,440 If it has a negative real part with a small enough 515 00:31:43,440 --> 00:31:47,646 [? timestamp, ?] you're going to make lambda times 516 00:31:47,646 --> 00:31:51,220 delta t into this region. 517 00:31:51,220 --> 00:31:52,874 What we're not concerned about is 518 00:31:52,874 --> 00:31:56,698 where lambda has a positive real part because the differential 519 00:31:56,698 --> 00:32:01,550 equation is unstable, and we don't want to solve it anyway. 520 00:32:01,550 --> 00:32:05,180 I mean, we don't expect it to be stable. 521 00:32:05,180 --> 00:32:07,720 Yeah, right. 522 00:32:07,720 --> 00:32:08,950 So right. 523 00:32:08,950 --> 00:32:14,580 So we don't really expect our scheme to be stable. 524 00:32:14,580 --> 00:32:16,729 If it's stable, then it is artificially stable 525 00:32:16,729 --> 00:32:19,020 because the real solution here is going to be unstable. 526 00:32:22,350 --> 00:32:29,051 Backward Euler, [INAUDIBLE] OK, we 527 00:32:29,051 --> 00:32:31,050 can see that, for any differential equation that 528 00:32:31,050 --> 00:32:37,160 is actually stable, backward Euler is stable. 529 00:32:37,160 --> 00:32:43,855 The blue region is [INAUDIBLE] no matter how big delta t is-- 530 00:32:43,855 --> 00:32:47,230 you can make delta t equal to 1,000 if you like, 531 00:32:47,230 --> 00:32:52,120 backward Euler is [INAUDIBLE] stable. 532 00:32:52,120 --> 00:32:57,080 So even in this region, where the real differential equation 533 00:32:57,080 --> 00:33:02,120 is unstable, artificially makes the solution stable, 534 00:33:02,120 --> 00:33:06,280 which actually gives you a wrong answer, but [INAUDIBLE] stable. 535 00:33:06,280 --> 00:33:06,780 [LAUGHTER] 536 00:33:06,780 --> 00:33:09,200 All right. 537 00:33:09,200 --> 00:33:11,500 Trapezoidal rule. 538 00:33:11,500 --> 00:33:16,285 That is, like, yeah, you said that's what 539 00:33:16,285 --> 00:33:19,090 we want because, if you look at the stability 540 00:33:19,090 --> 00:33:23,580 ratio of trapezoidal rule, it is exactly the same stability 541 00:33:23,580 --> 00:33:27,770 region as the analytical ODE. 542 00:33:27,770 --> 00:33:29,820 It doesn't always mean you're going 543 00:33:29,820 --> 00:33:34,250 to get the expected behavior because you're 544 00:33:34,250 --> 00:33:37,664 going to see is my lambda delta t is always here, 545 00:33:37,664 --> 00:33:41,750 the rate of decay of the trapezoidal rule 546 00:33:41,750 --> 00:33:44,810 versus the real ODE is going to be very different. 547 00:33:44,810 --> 00:33:47,420 So like, at least in terms of stability reading, 548 00:33:47,420 --> 00:33:53,630 it is exactly what you have for the analytical ODE. 549 00:33:53,630 --> 00:33:55,290 And the wrong [INAUDIBLE] schemes 550 00:33:55,290 --> 00:33:59,780 is something you are going to learn later on for this week's 551 00:33:59,780 --> 00:34:00,490 reading. 552 00:34:00,490 --> 00:34:04,150 But you're going to see these weird shapes. 553 00:34:04,150 --> 00:34:09,000 The [INAUDIBLE] schemes are explicit schemes. 554 00:34:09,000 --> 00:34:11,400 So for non-linear differential equations, 555 00:34:11,400 --> 00:34:15,030 you're going to see very soon that explicit schemes are 556 00:34:15,030 --> 00:34:19,440 a lot easier to implement than implicit schemes. 557 00:34:19,440 --> 00:34:24,750 And, for example, is great because it 558 00:34:24,750 --> 00:34:28,980 combines the advantage of forward Euler and midpoint. 559 00:34:28,980 --> 00:34:31,020 Why? 560 00:34:31,020 --> 00:34:42,770 Because as long as my lambda has a non-positive real part, 561 00:34:42,770 --> 00:34:46,030 as long as I make delta t small enough, 562 00:34:46,030 --> 00:34:49,639 I'm going to get into the stability region. 563 00:34:49,639 --> 00:34:54,590 Forward Euler requires me to have a negative real part. 564 00:34:54,590 --> 00:34:57,510 Midpoint requires me to have a zero real part. 565 00:34:57,510 --> 00:35:03,151 [INAUDIBLE] requires me to have either 0 or negative real part. 566 00:35:03,151 --> 00:35:04,650 And I can make delta t small enough. 567 00:35:04,650 --> 00:35:05,952 It is going to work. 568 00:35:09,284 --> 00:35:10,745 All right. 569 00:35:10,745 --> 00:35:11,245 Questions? 570 00:35:14,220 --> 00:35:16,000 Yeah? 571 00:35:16,000 --> 00:35:18,000 AUDIENCE: [INAUDIBLE] 572 00:35:38,000 --> 00:35:44,580 PROFESSOR: Eigenvalue stability concerns about an equation 573 00:35:44,580 --> 00:35:48,500 that is dx dt equal to lambda x. 574 00:35:48,500 --> 00:35:52,420 We are looking at, if I apply the scheme, 575 00:35:52,420 --> 00:35:56,250 we [? sub ?] delta t to this equation. 576 00:35:56,250 --> 00:35:58,180 Am I going to get a growing solution, 577 00:35:58,180 --> 00:35:59,840 or I'm going to get a stable solution? 578 00:36:03,340 --> 00:36:05,795 AUDIENCE: Is there a way [INAUDIBLE]? 579 00:36:19,184 --> 00:36:20,600 PROFESSOR: The stability region is 580 00:36:20,600 --> 00:36:21,949 different for each [INAUDIBLE]. 581 00:36:21,949 --> 00:36:22,490 AUDIENCE: OK. 582 00:36:22,490 --> 00:36:24,202 PROFESSOR: So you have to-- yeah, 583 00:36:24,202 --> 00:36:26,924 it's separate from the [INAUDIBLE] solution. 584 00:36:26,924 --> 00:36:33,740 For each combination of scheme and lambda delta t, 585 00:36:33,740 --> 00:36:37,250 you have an answer of yes or no. 586 00:36:37,250 --> 00:36:41,210 AUDIENCE: [INAUDIBLE] eigenvalue. 587 00:36:41,210 --> 00:36:44,675 [INAUDIBLE] eigenvalue. 588 00:36:44,675 --> 00:36:50,615 [INAUDIBLE] eigenvalue. 589 00:36:50,615 --> 00:36:52,595 [INAUDIBLE] 590 00:37:31,056 --> 00:37:31,680 PROFESSOR: Yes. 591 00:37:31,680 --> 00:37:37,887 AUDIENCE: [INAUDIBLE] and then you linearize it. 592 00:37:37,887 --> 00:37:40,816 But because of your error [INAUDIBLE]. 593 00:37:43,780 --> 00:37:46,610 This sort of method [INAUDIBLE]. 594 00:37:58,567 --> 00:38:00,650 PROFESSOR: I don't have a definite answer to that, 595 00:38:00,650 --> 00:38:02,640 but it's possible. 596 00:38:02,640 --> 00:38:05,740 And what I want to emphasize is that, 597 00:38:05,740 --> 00:38:09,883 if you linearize the equation, and eigenvalue stability 598 00:38:09,883 --> 00:38:14,210 shows that it is unstable, then it's very likely, 599 00:38:14,210 --> 00:38:17,018 when you apply to your [? normal ?] equation, 600 00:38:17,018 --> 00:38:19,190 that it's going to be unstable. 601 00:38:19,190 --> 00:38:24,360 So eigenvalue stability, I would say 602 00:38:24,360 --> 00:38:28,550 before you apply the scheme to differential equation, 603 00:38:28,550 --> 00:38:32,480 it's a good idea to check eigenvalue stability. 604 00:38:32,480 --> 00:38:34,560 And this also gives you a guidance 605 00:38:34,560 --> 00:38:39,020 of when you see something being unstable. 606 00:38:39,020 --> 00:38:42,200 Is it because you are using the wrong scheme? 607 00:38:42,200 --> 00:38:45,854 Or is it because you have a too large [INAUDIBLE]. 608 00:38:45,854 --> 00:38:46,840 Right? 609 00:38:46,840 --> 00:38:50,104 You can take a look at these eigenvalues 610 00:38:50,104 --> 00:38:52,546 and figure out which case it is. 611 00:38:56,489 --> 00:38:57,322 Any other questions? 612 00:39:00,100 --> 00:39:04,950 OK, let me give you a challenge. 613 00:39:04,950 --> 00:39:10,464 Now, if I get a couple differential equations 614 00:39:10,464 --> 00:39:18,471 [INAUDIBLE] where y is equal to x, where x can 615 00:39:18,471 --> 00:39:21,180 range all the way from 0 to t. 616 00:39:21,180 --> 00:39:25,760 For what x [INAUDIBLE] delta t is forward Euler table. 617 00:39:25,760 --> 00:39:30,044 For what values of [INAUDIBLE] is backward Euler table. 618 00:39:30,044 --> 00:39:32,210 And for what value of epsilon is it midpoint stable? 619 00:39:32,210 --> 00:39:34,980 I mean, not for epsilon, but for what 620 00:39:34,980 --> 00:39:38,584 combination of epsilon and delta t is each of these [INAUDIBLE]. 621 00:39:38,584 --> 00:39:43,530 Form groups of two or three, and figure this out. 622 00:39:43,530 --> 00:39:44,910 All right. 623 00:39:44,910 --> 00:39:48,020 A lot of you have got the answer, 624 00:39:48,020 --> 00:39:50,953 or almost get the answer, and let 625 00:39:50,953 --> 00:39:58,080 me do it here to make sure everybody is on the same page. 626 00:39:58,080 --> 00:40:00,710 First of all, the first step is to write the differential 627 00:40:00,710 --> 00:40:02,540 equation into a matrix form. 628 00:40:06,660 --> 00:40:12,230 The du dt of x and y, let's write it in a similar way 629 00:40:12,230 --> 00:40:14,545 as du dt equals lambda u. 630 00:40:14,545 --> 00:40:16,980 But here, the lambda is no longer a number. 631 00:40:16,980 --> 00:40:17,995 It is a matrix. 632 00:40:20,560 --> 00:40:23,180 And what is the matrix? 633 00:40:23,180 --> 00:40:25,180 Just fill in the blanks. 634 00:40:25,180 --> 00:40:27,680 dx dt minus y minus epsilon x. 635 00:40:27,680 --> 00:40:31,490 So minus epsilon x minus 1y. 636 00:40:31,490 --> 00:40:35,030 dy dt equal to x, so 1x plus 0y. 637 00:40:37,840 --> 00:40:40,300 OK, so I get a matrix here. 638 00:40:40,300 --> 00:40:43,270 And how do I go from the matrix to eigenvalue stability? 639 00:40:47,190 --> 00:40:49,710 Take the eigenvalue. 640 00:40:49,710 --> 00:40:50,920 Take the eigenvalue. 641 00:40:50,920 --> 00:40:56,130 So the eigenvalue of this matrix, and I may be lazy, 642 00:40:56,130 --> 00:40:58,788 so let me do it in Matlab. 643 00:40:58,788 --> 00:41:00,011 [LAUGHTER] 644 00:41:00,011 --> 00:41:00,510 OK? 645 00:41:04,060 --> 00:41:07,940 Yeah, so for this 2 by 2 matrix, you can do it by hand. 646 00:41:07,940 --> 00:41:10,682 But if you get a large matrix, what do you do? 647 00:41:15,750 --> 00:41:17,531 Let me do the bad example. 648 00:41:17,531 --> 00:41:18,406 AUDIENCE: [INAUDIBLE] 649 00:41:24,210 --> 00:41:26,400 PROFESSOR: OK, I'm just going to make epsilon 650 00:41:26,400 --> 00:41:29,160 go all the way from 0 to 10. 651 00:41:29,160 --> 00:41:33,672 So linked space is putting a bunch of epsilon. 652 00:41:33,672 --> 00:41:38,300 And the matrix here is going to be like this. 653 00:41:38,300 --> 00:41:40,130 So let me do this. 654 00:41:40,130 --> 00:41:48,910 Let me put e to be a symbolic variable. 655 00:41:48,910 --> 00:41:52,310 And the matrix is what? 656 00:41:52,310 --> 00:41:57,080 Minus e minus 1, 1, 0. 657 00:41:57,080 --> 00:41:59,840 So that's what the matrix is. 658 00:41:59,840 --> 00:42:02,000 And e means epsilon. 659 00:42:02,000 --> 00:42:06,650 And you can do the eigenvalue of this matrix. 660 00:42:06,650 --> 00:42:11,090 It gives you the formula, which you guys have figured out. 661 00:42:11,090 --> 00:42:18,083 Minus epsilon over 2 plus or minus the square root of-- I 662 00:42:18,083 --> 00:42:21,810 mean, to the 1/2 power is basically square root, right, 663 00:42:21,810 --> 00:42:23,770 of this thing. 664 00:42:23,770 --> 00:42:29,536 So let me just again say, epsilon e 665 00:42:29,536 --> 00:42:35,560 is equal to linked space of 0, 10, 100. 666 00:42:35,560 --> 00:42:40,250 And I'm going to say lambda 1, the first eigenvalue 667 00:42:40,250 --> 00:42:44,110 is-- I'm just going to copy the formula here and paste it. 668 00:42:47,700 --> 00:42:50,040 And I need to convert the products 669 00:42:50,040 --> 00:42:55,540 into dot and exponenting to dot exponential. 670 00:42:55,540 --> 00:42:59,490 And everything else is going to be fine. 671 00:42:59,490 --> 00:43:09,770 I'm going to also look at the second eigenvalue. 672 00:43:09,770 --> 00:43:14,060 I'm going to paste it and also do the dot product and dot 673 00:43:14,060 --> 00:43:15,520 explanation. 674 00:43:15,520 --> 00:43:17,890 OK, I have L1 and L2. 675 00:43:17,890 --> 00:43:18,850 Let me plot them. 676 00:43:21,840 --> 00:43:24,680 I'm going to plot a line and dot. 677 00:43:24,680 --> 00:43:27,250 So what you get is, in the complex plan, 678 00:43:27,250 --> 00:43:31,620 let me do x is equal-- in a complex plan, 679 00:43:31,620 --> 00:43:35,300 I'm plotting the trajectory of lambda, 680 00:43:35,300 --> 00:43:42,530 of lambda 1, as my epsilon goes from 0 to 10. 681 00:43:42,530 --> 00:43:52,540 I'm going to say hold on and plot the evolution of lambda 2. 682 00:43:52,540 --> 00:43:56,160 Actually, I want to plot it in a different color. 683 00:43:56,160 --> 00:44:03,074 So you get a [INAUDIBLE] of lambda 1, but this way, 684 00:44:03,074 --> 00:44:04,445 [INAUDIBLE]. 685 00:44:04,445 --> 00:44:06,700 And remember, this is, in the context [INAUDIBLE], 686 00:44:06,700 --> 00:44:11,350 the two eigenvalues, right? 687 00:44:11,350 --> 00:44:13,990 OK, anybody remind me what is the stability 688 00:44:13,990 --> 00:44:15,323 region of forward Euler? 689 00:44:15,323 --> 00:44:16,198 AUDIENCE: [INAUDIBLE] 690 00:44:19,390 --> 00:44:23,115 PROFESSOR: Yeah, so a circle around negative 1. 691 00:44:23,115 --> 00:44:28,150 So a circle around negative 1, right? 692 00:44:28,150 --> 00:44:32,050 Going to the Matlab plot, it's a circle around here. 693 00:44:34,620 --> 00:44:37,486 But remember, the stability region 694 00:44:37,486 --> 00:44:40,566 is a stability region of what? 695 00:44:40,566 --> 00:44:41,880 Of lambda t. 696 00:44:41,880 --> 00:44:43,890 Lambda times t. 697 00:44:43,890 --> 00:44:46,988 Well here, I'm just plotting the lambda. 698 00:44:46,988 --> 00:44:49,368 So what does that mean? 699 00:44:49,368 --> 00:44:53,400 If I have, let's see, epsilon equal to 10, 700 00:44:53,400 --> 00:44:55,900 one of my eigenvalues is here. 701 00:44:55,900 --> 00:44:57,360 Is there any hope? 702 00:44:57,360 --> 00:44:59,040 I mean, the [INAUDIBLE]. 703 00:44:59,040 --> 00:45:02,496 Is there any hope of making forward Euler stable? 704 00:45:02,496 --> 00:45:04,430 AUDIENCE: [INAUDIBLE] 705 00:45:04,430 --> 00:45:05,783 PROFESSOR: How? 706 00:45:05,783 --> 00:45:08,040 AUDIENCE: [INAUDIBLE] 707 00:45:08,040 --> 00:45:11,930 PROFESSOR: By a big delta t equal to how much? 708 00:45:11,930 --> 00:45:14,140 Or a small delta t? 709 00:45:14,140 --> 00:45:17,106 A small delta t equal to how much? 710 00:45:17,106 --> 00:45:17,606 Huh? 711 00:45:20,510 --> 00:45:22,304 AUDIENCE: [INAUDIBLE] 712 00:45:22,304 --> 00:45:23,220 PROFESSOR: [INAUDIBLE] 713 00:45:27,272 --> 00:45:29,899 AUDIENCE: [INAUDIBLE] 714 00:45:29,899 --> 00:45:31,690 PROFESSOR: As long as I can make this point 715 00:45:31,690 --> 00:45:36,670 with being the [INAUDIBLE], where the [INAUDIBLE] here 716 00:45:36,670 --> 00:45:38,150 is minus 2, right? 717 00:45:38,150 --> 00:45:42,116 So as long as I can have a delta t that is less than 1, 2, 718 00:45:42,116 --> 00:45:45,950 I can make forward Euler stable. 719 00:45:45,950 --> 00:45:47,565 Any questions on that? 720 00:45:47,565 --> 00:45:48,440 AUDIENCE: [INAUDIBLE] 721 00:45:55,912 --> 00:45:57,120 PROFESSOR: Yeah, right, sure. 722 00:46:03,565 --> 00:46:04,440 AUDIENCE: [INAUDIBLE] 723 00:46:15,176 --> 00:46:18,246 PROFESSOR: OK, you have beat me. 724 00:46:18,246 --> 00:46:32,030 AUDIENCE: [INAUDIBLE] that lambda [INAUDIBLE]. 725 00:46:35,770 --> 00:46:37,240 PROFESSOR: Yeah, right. 726 00:46:37,240 --> 00:46:38,550 OK, thank you. 727 00:46:38,550 --> 00:46:39,425 AUDIENCE: [INAUDIBLE] 728 00:46:43,367 --> 00:46:44,075 PROFESSOR: Right. 729 00:46:44,075 --> 00:46:54,150 So we have to make [INAUDIBLE] stability region. 730 00:46:56,717 --> 00:46:59,640 So, question? 731 00:46:59,640 --> 00:47:01,990 OK. 732 00:47:01,990 --> 00:47:06,670 And so we can see, when epsilon is very large, 733 00:47:06,670 --> 00:47:09,161 it's difficult to-- you have to have a small delta 734 00:47:09,161 --> 00:47:11,370 t to shrink it [INAUDIBLE]. 735 00:47:11,370 --> 00:47:14,780 Another case is when epsilon is very small, 736 00:47:14,780 --> 00:47:16,830 actually adds epsilon equal to zero. 737 00:47:16,830 --> 00:47:20,760 I get two eigenvalues equal to [INAUDIBLE]. 738 00:47:23,800 --> 00:47:26,620 How can I make the case stable for forward Euler? 739 00:47:34,450 --> 00:47:36,120 AUDIENCE: [INAUDIBLE] 740 00:47:36,120 --> 00:47:39,010 PROFESSOR: I can never make forward Euler stable. 741 00:47:39,010 --> 00:47:43,100 I can make delta t goes to very, very small, [INAUDIBLE] shrink 742 00:47:43,100 --> 00:47:43,600 over here. 743 00:47:43,600 --> 00:47:47,180 But they are still on the [INAUDIBLE]. 744 00:47:47,180 --> 00:47:54,824 And remember forward Euler, it doesn't include any point 745 00:47:54,824 --> 00:47:57,520 on the imaginary axis other than 0. 746 00:47:57,520 --> 00:48:02,290 So when 1 epsilon is very small, it's 747 00:48:02,290 --> 00:48:04,170 impossible to make forward Euler stable. 748 00:48:04,170 --> 00:48:07,830 And when epsilon is very small, it 749 00:48:07,830 --> 00:48:10,630 takes a very, very small delta t [INAUDIBLE]. 750 00:48:13,752 --> 00:48:24,250 So when a system is [INAUDIBLE], it's almost pure oscillation. 751 00:48:24,250 --> 00:48:27,735 It also takes a lot of [INAUDIBLE] 752 00:48:27,735 --> 00:48:31,775 for very small delta t for forward Euler 753 00:48:31,775 --> 00:48:35,150 to accurately resolve its behavior. 754 00:48:35,150 --> 00:48:35,918 Yes? 755 00:48:35,918 --> 00:48:36,793 AUDIENCE: [INAUDIBLE] 756 00:48:43,561 --> 00:48:44,602 PROFESSOR: Good question. 757 00:48:44,602 --> 00:48:48,684 Does both Eigenvalues need to be in the stability region? 758 00:48:48,684 --> 00:48:50,672 AUDIENCE: [INAUDIBLE] 759 00:49:10,570 --> 00:49:11,270 PROFESSOR: Yes. 760 00:49:11,270 --> 00:49:13,470 Both eigenvalues, or all of the eigenvalues, 761 00:49:13,470 --> 00:49:16,430 in this case, with two eigenvalues, [INAUDIBLE] 762 00:49:16,430 --> 00:49:21,330 all of the eigenvalues have to be in the [INAUDIBLE] region. 763 00:49:21,330 --> 00:49:28,178 And the eigenvalues of a matrix doesn't always 764 00:49:28,178 --> 00:49:29,126 conjugate each other. 765 00:49:29,126 --> 00:49:32,430 And in this case, [INAUDIBLE] conjugate each other. 766 00:49:32,430 --> 00:49:34,895 And as our epsilon [INAUDIBLE]. 767 00:49:41,180 --> 00:49:44,475 And if you have a bigger matrix, that's even more [INAUDIBLE]. 768 00:49:44,475 --> 00:49:45,350 AUDIENCE: [INAUDIBLE] 769 00:50:37,540 --> 00:50:38,280 PROFESSOR: Right. 770 00:50:38,280 --> 00:50:42,240 The instability analysis of the analytical system, 771 00:50:42,240 --> 00:50:45,762 the analytical system is stable for the whole [INAUDIBLE]. 772 00:50:45,762 --> 00:50:47,970 So you are looking at the most dangerous [INAUDIBLE]. 773 00:50:52,670 --> 00:50:54,210 Where we have a numerical scheme, 774 00:50:54,210 --> 00:50:57,460 the most dangerous ones are not necessarily 775 00:50:57,460 --> 00:51:01,060 the one that lies towards the right. 776 00:51:01,060 --> 00:51:04,750 It made be the ones that lies more towards the left. 777 00:51:04,750 --> 00:51:09,410 Or most [? low, ?] most dangerous, 778 00:51:09,410 --> 00:51:10,720 of the stability region. 779 00:51:10,720 --> 00:51:12,475 They are not necessarily the ones 780 00:51:12,475 --> 00:51:16,995 that is closest to the imaginary axis. 781 00:51:16,995 --> 00:51:17,870 AUDIENCE: [INAUDIBLE] 782 00:51:27,500 --> 00:51:29,000 PROFESSOR: Yeah. 783 00:51:29,000 --> 00:51:30,710 AUDIENCE: [INAUDIBLE] 784 00:52:01,304 --> 00:52:03,763 PROFESSOR: Yeah, for nonlinear problems, 785 00:52:03,763 --> 00:52:07,130 sometimes [? they are ?] very extremely important to adapt 786 00:52:07,130 --> 00:52:10,099 the timestamp according to-- because they have different 787 00:52:10,099 --> 00:52:12,140 [? phase, ?] and different parts of the solution, 788 00:52:12,140 --> 00:52:14,710 when you linearize the nonlinear equations, 789 00:52:14,710 --> 00:52:17,796 you get different eigenvalues. 790 00:52:17,796 --> 00:52:21,765 So when you get the big eigenvalues, or [INAUDIBLE], 791 00:52:21,765 --> 00:52:25,320 it's important to make [? them ?] small. 792 00:52:25,320 --> 00:52:28,440 Any other questions? 793 00:52:28,440 --> 00:52:29,420 OK. 794 00:52:29,420 --> 00:52:31,825 Let me pose another change question. 795 00:52:41,530 --> 00:52:42,270 Oh, right. 796 00:52:42,270 --> 00:52:43,710 OK. 797 00:52:43,710 --> 00:52:46,610 Yes, what about midpoint? 798 00:52:46,610 --> 00:52:51,506 If you look at the eigenvalues, will they work for midpoint? 799 00:52:58,320 --> 00:53:01,370 Only when epsilon is equal to 0. 800 00:53:01,370 --> 00:53:04,730 Only when epsilon is equal to 0, we get equal eigenvalues. 801 00:53:04,730 --> 00:53:08,130 And for what delta t would midpoint be stable? 802 00:53:16,280 --> 00:53:18,670 Less or equal to 1, right? 803 00:53:18,670 --> 00:53:22,350 Because the stability region for midpoint, 804 00:53:22,350 --> 00:53:25,432 when looking at lambda times delta t, that [INAUDIBLE] 805 00:53:25,432 --> 00:53:27,400 midpoint to midpoint. 806 00:53:27,400 --> 00:53:29,320 If you make delta t lambda equal to 1, 807 00:53:29,320 --> 00:53:32,270 then the [INAUDIBLE] pinpoints was [INAUDIBLE] 808 00:53:32,270 --> 00:53:33,510 into the [INAUDIBLE]. 809 00:53:33,510 --> 00:53:35,670 If you make delta t greater than 1, 810 00:53:35,670 --> 00:53:39,240 you will push this point in the lambda delta t [INAUDIBLE] 811 00:53:39,240 --> 00:53:40,899 out of the [INAUDIBLE]. 812 00:53:46,650 --> 00:53:51,860 You'll find a scheme where it will be stable 813 00:53:51,860 --> 00:53:59,280 for all of the actions-- trapezoidal, right? 814 00:53:59,280 --> 00:54:03,030 Because the trapezoidal rule has a stability region 815 00:54:03,030 --> 00:54:05,798 that covers the whole left panel. 816 00:54:05,798 --> 00:54:08,410 And we are looking at the whole left panel over here. 817 00:54:08,410 --> 00:54:08,910 What else? 818 00:54:12,640 --> 00:54:15,290 The [INAUDIBLE] is called a [INAUDIBLE]. 819 00:54:15,290 --> 00:54:22,040 OK, that has a stability region somewhere like [INAUDIBLE] 820 00:54:22,040 --> 00:54:26,070 or something like that. 821 00:54:26,070 --> 00:54:30,234 We can have a small delta t that would bring the whole thing 822 00:54:30,234 --> 00:54:32,530 into the [INAUDIBLE]. 823 00:54:32,530 --> 00:54:34,226 OK, yes? 824 00:54:34,226 --> 00:54:35,142 AUDIENCE: [INAUDIBLE]. 825 00:54:37,496 --> 00:54:39,370 PROFESSOR: How do you find a stability region 826 00:54:39,370 --> 00:54:40,600 for various methods? 827 00:54:40,600 --> 00:54:41,960 Good point. 828 00:54:41,960 --> 00:54:43,765 I have showed you how to find the stability 829 00:54:43,765 --> 00:54:44,806 region for forward Euler. 830 00:54:47,440 --> 00:54:49,390 I have showed you how to find the stability 831 00:54:49,390 --> 00:54:52,540 region for forward Euler by basically 832 00:54:52,540 --> 00:54:57,960 plugging du dt for the lambda u into the scheme. 833 00:54:57,960 --> 00:55:00,550 I'm going to show you another example of doing this 834 00:55:00,550 --> 00:55:02,890 for midpoint, all right? 835 00:55:02,890 --> 00:55:05,540 OK, if you have a midpoint, you have 836 00:55:05,540 --> 00:55:13,420 a Vn plus 1 equal to Vn minus 1 plus 2 delta t times 837 00:55:13,420 --> 00:55:14,460 half of Vn. 838 00:55:18,400 --> 00:55:22,100 I can do this example, but you've got to help me. 839 00:55:22,100 --> 00:55:25,080 What's next? 840 00:55:25,080 --> 00:55:28,180 When I analyze eigenvalue stability, what do I do next? 841 00:55:30,832 --> 00:55:32,040 What is eigenvalue stability? 842 00:55:35,165 --> 00:55:36,040 AUDIENCE: [INAUDIBLE] 843 00:55:42,255 --> 00:55:42,880 PROFESSOR: Yes. 844 00:55:42,880 --> 00:55:46,590 Eigenvalue basically shows is the skill [INAUDIBLE] 845 00:55:46,590 --> 00:55:50,270 for [INAUDIBLE] equal to lambda u. 846 00:55:50,270 --> 00:55:52,660 So basically, we are asking, is the scheme 847 00:55:52,660 --> 00:55:55,770 stable for this differential equation. 848 00:55:55,770 --> 00:56:00,798 So when we look at these as f of u, we get lambda times Vn. 849 00:56:03,720 --> 00:56:07,740 OK, so I'm going to write it down again. 850 00:56:07,740 --> 00:56:14,080 This is what we want to analyze [INAUDIBLE] exponentially 851 00:56:14,080 --> 00:56:17,950 growing solution or not. 852 00:56:17,950 --> 00:56:19,600 How do I analyze if it [INAUDIBLE] 853 00:56:19,600 --> 00:56:22,926 the exponentially growing solution or not? 854 00:56:26,500 --> 00:56:28,340 I'm going to try one. 855 00:56:28,340 --> 00:56:33,920 I'm going to try to say Vm plus 1 is equal to V0 times Z 856 00:56:33,920 --> 00:56:35,530 to the n plus 1. 857 00:56:35,530 --> 00:56:41,110 Vn equal to V0 times [INAUDIBLE] minus 1 equal to V0 times Z 858 00:56:41,110 --> 00:56:42,750 to the n minus 1. 859 00:56:42,750 --> 00:56:45,200 I'm just going to try 1, try an exponential growing 860 00:56:45,200 --> 00:56:48,570 solution to see if it is possible for Z 861 00:56:48,570 --> 00:56:51,840 to be something greater than 1 or less than minus 1, 862 00:56:51,840 --> 00:56:56,576 or having an imaginary having a complex value that 863 00:56:56,576 --> 00:56:58,400 has a modulus greater than 1. 864 00:56:58,400 --> 00:57:00,340 But if it's one of these cases, I'm 865 00:57:00,340 --> 00:57:03,390 going to get an unstable scheme. 866 00:57:03,390 --> 00:57:05,240 OK, let me plug this in, and I'm going 867 00:57:05,240 --> 00:57:07,130 to cancel all of these zeroes. 868 00:57:07,130 --> 00:57:10,120 What I'm going to get is Z to the n plus 1 power. 869 00:57:10,120 --> 00:57:14,500 Power is equal to z to the n minus 1 power. 870 00:57:14,500 --> 00:57:16,460 I mean, these are time steps. 871 00:57:16,460 --> 00:57:17,670 These are time steps. 872 00:57:17,670 --> 00:57:22,650 Now what I get is to the powers. 873 00:57:22,650 --> 00:57:26,350 I'm going to do parenthesis to denote time steps and the ones 874 00:57:26,350 --> 00:57:29,230 without parentheses to denote power. 875 00:57:29,230 --> 00:57:31,730 Oh, this is a plus, sorry. 876 00:57:31,730 --> 00:57:37,030 Plus 2 delta t times lambda Z to the n. 877 00:57:37,030 --> 00:57:38,040 OK, what do I do next? 878 00:57:42,780 --> 00:57:45,630 AUDIENCE: [INAUDIBLE] 879 00:57:45,630 --> 00:57:49,140 PROFESSOR: Factor out Z to the n minus 1. 880 00:57:49,140 --> 00:57:52,550 I'm going to get a quadratic equation 881 00:57:52,550 --> 00:57:56,775 equal to 1 plus 2 delta t lambda times z. 882 00:57:59,720 --> 00:58:03,280 OK, now I can't get the solution for z 883 00:58:03,280 --> 00:58:08,060 to see if it can lead to an exponentially growing solution 884 00:58:08,060 --> 00:58:09,260 or not. 885 00:58:09,260 --> 00:58:14,430 So I believe I get 2 lambda delta 886 00:58:14,430 --> 00:58:22,890 t plus minus square root of 4 lambda 887 00:58:22,890 --> 00:58:27,182 squared delta t squared plus 4. 888 00:58:38,710 --> 00:58:44,440 So let me go [INAUDIBLE]. 889 00:58:44,440 --> 00:58:48,660 OK, so this is the Z I got. 890 00:58:48,660 --> 00:58:56,770 I want this Z to have a modulus less or equal to 1. 891 00:59:09,466 --> 00:59:24,491 [INAUDIBLE] And this 2, divided by 2, if lambda is-- so let's 892 00:59:24,491 --> 00:59:24,990 proceed. 893 00:59:24,990 --> 00:59:31,440 If lambda is a real value, if lambda is anything real, 894 00:59:31,440 --> 00:59:33,516 and nonzero, then lambda squared is 895 00:59:33,516 --> 00:59:35,050 going to be something positive. 896 00:59:35,050 --> 00:59:38,280 And what I get is something greater than 4. 897 00:59:38,280 --> 00:59:42,626 And the square root is going to be something greater than 2. 898 00:59:46,084 --> 00:59:51,360 So because I have a plus or minus, one of them 899 00:59:51,360 --> 00:59:55,156 is going to have a magnitude greater than 2. 900 00:59:55,156 --> 00:59:58,660 When divided by 2, I'm going to get something greater than 1. 901 00:59:58,660 --> 01:00:01,220 So for any real lambda, I'm going to be on unstable. 902 01:00:04,000 --> 01:00:10,080 And you can also figure out, for complex values of lambda, 903 01:00:10,080 --> 01:00:11,910 what values is going to make it stable, 904 01:00:11,910 --> 01:00:14,360 what value is not going to make it stable. 905 01:00:14,360 --> 01:00:21,785 And in fact, [INAUDIBLE] for all the values of lambda delta t, 906 01:00:21,785 --> 01:00:27,340 that will make this Z having a modulus of exactly 31. 907 01:00:31,080 --> 01:00:34,520 So if this has a value exactly 31, 908 01:00:34,520 --> 01:00:37,040 my [? schema ?] is going to be exactly 909 01:00:37,040 --> 01:00:41,140 on the boundary of stability. 910 01:00:41,140 --> 01:00:44,130 So if I have all this level 1, I'm going to be stable. 911 01:00:44,130 --> 01:00:47,060 If I have 1 z that is greater than 1, 912 01:00:47,060 --> 01:00:53,910 if I have [INAUDIBLE] modulus, [INAUDIBLE], 913 01:00:53,910 --> 01:00:54,940 I'm on the boundary. 914 01:00:54,940 --> 01:01:01,500 So by [INAUDIBLE], I'm going to compute 915 01:01:01,500 --> 01:01:03,820 the boundary of the stability region, which 916 01:01:03,820 --> 01:01:06,656 gives me something like this. 917 01:01:06,656 --> 01:01:12,520 So if I take the boundary [INAUDIBLE] modulus 1, 918 01:01:12,520 --> 01:01:15,935 I'm going to block its boundary of stability. 919 01:01:15,935 --> 01:01:20,010 [INAUDIBLE] Yeah? 920 01:01:20,010 --> 01:01:20,885 AUDIENCE: [INAUDIBLE] 921 01:02:10,385 --> 01:02:11,760 PROFESSOR: Yeah, Professor Wilcox 922 01:02:11,760 --> 01:02:19,199 is saying that, when you look at this equation, and plug in Z 923 01:02:19,199 --> 01:02:21,590 is equal to e to the ith theta, you're 924 01:02:21,590 --> 01:02:25,590 going to get Z squared, which is e to the 2i theta is 925 01:02:25,590 --> 01:02:30,280 equal to 1 plus 2 times delta t lambda times 926 01:02:30,280 --> 01:02:33,370 z, which is e to the ith theta. 927 01:02:33,370 --> 01:02:34,245 AUDIENCE: [INAUDIBLE] 928 01:02:39,952 --> 01:02:40,660 PROFESSOR: Right. 929 01:02:40,660 --> 01:02:41,717 And then-- 930 01:02:41,717 --> 01:02:42,592 AUDIENCE: [INAUDIBLE] 931 01:02:51,780 --> 01:02:54,960 PROFESSOR: Right, and you can figure out the stability 932 01:02:54,960 --> 01:02:59,378 boundary for delta t lambda using [INAUDIBLE]. 933 01:03:12,090 --> 01:03:12,590 All right. 934 01:03:12,590 --> 01:03:13,300 OK. 935 01:03:13,300 --> 01:03:17,180 Let me show you one last thing. 936 01:03:17,180 --> 01:03:21,030 What if you have a du dt equal to minus u squared? 937 01:03:26,212 --> 01:03:27,420 We get a non-linear equation. 938 01:03:30,540 --> 01:03:32,570 For what scheme would this be stable? 939 01:03:32,570 --> 01:03:34,465 What scheme this would be unstable? 940 01:03:43,020 --> 01:03:48,100 The analysis of this scheme lies in linearization. 941 01:03:48,100 --> 01:03:51,770 OK, so let's say, if I have a u of 0 942 01:03:51,770 --> 01:03:54,170 at t equal to 0 equal to 1. 943 01:03:54,170 --> 01:03:55,560 OK. 944 01:03:55,560 --> 01:03:57,790 What if I linearize this question? 945 01:03:57,790 --> 01:04:03,520 What if I say, u, I'm going to put [INAUDIBLE] a u 946 01:04:03,520 --> 01:04:13,270 to u plus delta u, or plus a very small v. 947 01:04:13,270 --> 01:04:14,945 What is the result of the linearization? 948 01:04:17,510 --> 01:04:22,500 The linearization can be seen by plugging both the u and the u 949 01:04:22,500 --> 01:04:26,470 plus V into the differential equation. 950 01:04:26,470 --> 01:04:28,720 If you plug just the u, you get this. 951 01:04:28,720 --> 01:04:34,380 If you plus u plus v, you get du plus V 952 01:04:34,380 --> 01:04:40,940 dt equal to minus u plus V squared. 953 01:04:40,940 --> 01:04:47,670 And here is linearization V is very small. 954 01:04:47,670 --> 01:04:53,670 And because v is very small, you can derive du dt plus dv dt. 955 01:04:53,670 --> 01:04:58,320 This is just factorizing u plus v out of the derivative, 956 01:04:58,320 --> 01:05:03,050 is equal to minus u squared minus 2 uV, minus V squared. 957 01:05:03,050 --> 01:05:08,920 But because V is very small, this term is negligible. 958 01:05:08,920 --> 01:05:14,092 This term is very, very small, or very square small. 959 01:05:18,250 --> 01:05:19,340 OK. 960 01:05:19,340 --> 01:05:24,235 Now, when you look at the answer to the equation has a du dt. 961 01:05:24,235 --> 01:05:26,776 The right hand side has a minus u squared. 962 01:05:26,776 --> 01:05:28,710 The right hand side has a minus u squared. 963 01:05:28,710 --> 01:05:30,170 These two terms cancel out because 964 01:05:30,170 --> 01:05:32,260 of the answer to the equation. 965 01:05:32,260 --> 01:05:34,930 The only thing you get is the linearized equation dv 966 01:05:34,930 --> 01:05:38,710 dt equal or minus 2u times t. 967 01:05:49,724 --> 01:05:51,751 No, yes? 968 01:05:51,751 --> 01:05:54,360 No, yes? 969 01:05:54,360 --> 01:05:57,820 That's how you would linearize a nonlinear equation-- 970 01:05:57,820 --> 01:06:03,330 by perturbing the variable into the variable something very 971 01:06:03,330 --> 01:06:10,510 small and remove all other very, very small terms, and the very, 972 01:06:10,510 --> 01:06:13,410 very, very small [INAUDIBLE], if you have cubic terms. 973 01:06:16,370 --> 01:06:18,730 So now we have the linearized equation, which 974 01:06:18,730 --> 01:06:25,280 is linear with respect to V. Can somebody tell me, 975 01:06:25,280 --> 01:06:29,470 if I use forward Euler, when would this scheme be stable? 976 01:06:29,470 --> 01:06:32,880 When would my forward Euler be stable? 977 01:06:46,351 --> 01:06:47,226 AUDIENCE: [INAUDIBLE] 978 01:06:53,694 --> 01:06:54,360 PROFESSOR: Good. 979 01:06:54,360 --> 01:06:58,390 In this case, this is my lambda. 980 01:06:58,390 --> 01:07:02,490 I'm solving dv dt equal to minus 2u times v. My minus 2u 981 01:07:02,490 --> 01:07:03,620 is my lambda. 982 01:07:03,620 --> 01:07:06,056 This is where, like, you have a question 983 01:07:06,056 --> 01:07:07,960 of adaptive timestamping, right? 984 01:07:07,960 --> 01:07:10,716 This is when lambda actually depends on the solution 985 01:07:10,716 --> 01:07:13,420 U of the nonlinear equation. 986 01:07:13,420 --> 01:07:15,140 As I solve the nonlinear equation, 987 01:07:15,140 --> 01:07:20,014 my lambda of the linearized equation actually changes. 988 01:07:20,014 --> 01:07:22,430 So in the beginning, I mean, the solution of this equation 989 01:07:22,430 --> 01:07:24,720 looks like this. 990 01:07:24,720 --> 01:07:30,170 Actually, we figured out ut, I think, is equal to 1 over t 991 01:07:30,170 --> 01:07:31,780 plus 1 or something like that, right? 992 01:07:31,780 --> 01:07:34,720 In the first or second lecture we figured that out. 993 01:07:34,720 --> 01:07:40,330 So in the beginning, u is large, and minus 2u 994 01:07:40,330 --> 01:07:42,840 is kind of on the negative side, and big. 995 01:07:42,840 --> 01:07:45,320 We need to use a smaller timestamp. 996 01:07:45,320 --> 01:07:47,850 And later on, as you become smaller and smaller, 997 01:07:47,850 --> 01:07:50,570 we are allowed to use larger timestamps for forward Euler 998 01:07:50,570 --> 01:07:52,150 to be stable. 999 01:07:52,150 --> 01:07:55,070 This is a case where we actually can benefit 1000 01:07:55,070 --> 01:07:57,930 from adaptive timestamps. 1001 01:07:57,930 --> 01:08:05,420 The case is minus 2u has to be less than 0, equal to 0, 1002 01:08:05,420 --> 01:08:07,410 and greater than or equal to minus 2, 1003 01:08:07,410 --> 01:08:11,316 minus 2u times delta t because I am lambda delta t. 1004 01:08:14,960 --> 01:08:18,910 This is the stability for forward Euler. 1005 01:08:22,319 --> 01:08:24,140 Questions on this? 1006 01:08:24,140 --> 01:08:28,248 Is it clear how did I linearize this and apply 1007 01:08:28,248 --> 01:08:29,246 eigenvalue stability? 1008 01:08:37,230 --> 01:08:39,350 All right. 1009 01:08:39,350 --> 01:08:41,490 OK. 1010 01:08:41,490 --> 01:08:47,529 Now the last thing I want to do, not 1011 01:08:47,529 --> 01:08:49,720 sure I have time, but, like, I am 1012 01:08:49,720 --> 01:08:53,335 going to pose these as a question-- is how do I apply 1013 01:08:53,335 --> 01:08:56,689 backward Euler on this problem. 1014 01:08:56,689 --> 01:09:01,058 How do I apply backward Euler on this problem. 1015 01:09:04,382 --> 01:09:05,340 What is backward Euler? 1016 01:09:05,340 --> 01:09:08,279 Can somebody help me write down what backward Euler is? 1017 01:09:15,380 --> 01:09:16,655 OK, what backward Euler is? 1018 01:09:22,630 --> 01:09:25,370 What is forward Euler? 1019 01:09:25,370 --> 01:09:30,290 If I use forward Euler, what would it be equal to? 1020 01:09:30,290 --> 01:09:31,165 AUDIENCE: [INAUDIBLE] 1021 01:09:36,029 --> 01:09:40,609 PROFESSOR: Forward Euler would be e f of u to the n. 1022 01:09:40,609 --> 01:09:42,559 What would backward Euler be? 1023 01:09:52,459 --> 01:09:55,917 For f of u n is Forward Euler. 1024 01:09:55,917 --> 01:09:56,792 AUDIENCE: [INAUDIBLE] 1025 01:10:00,180 --> 01:10:03,230 PROFESSOR: Yeah, backward Euler is f of u to the n times 1. 1026 01:10:08,200 --> 01:10:10,130 So that that is backward Euler. 1027 01:10:10,130 --> 01:10:12,100 And in this particular case, I'm going 1028 01:10:12,100 --> 01:10:16,170 to get minus u n plus 1 squared. 1029 01:10:20,120 --> 01:10:23,350 I'm going to get an equation that looks like this. 1030 01:10:23,350 --> 01:10:24,750 How do I solve that equation? 1031 01:10:30,110 --> 01:10:33,600 If I get any answer that is good, 1032 01:10:33,600 --> 01:10:35,062 I'm going to end this class. 1033 01:10:41,210 --> 01:10:42,560 u n is known, right? 1034 01:10:42,560 --> 01:10:44,560 I'm at the nth concept. 1035 01:10:44,560 --> 01:10:46,420 So u n is known. 1036 01:10:46,420 --> 01:10:49,240 Let me put unknown in read. 1037 01:10:49,240 --> 01:10:52,645 u n plus 1 and the known in blue. 1038 01:11:15,800 --> 01:11:19,364 Yeah, that makes it a quadratic equation. 1039 01:11:19,364 --> 01:11:25,160 We get an unknown square, a linear, and a [INAUDIBLE]. 1040 01:11:25,160 --> 01:11:28,540 So we can see we need to solve a quadratic equation now 1041 01:11:28,540 --> 01:11:33,600 in order to go from one step to the next step. 1042 01:11:33,600 --> 01:11:37,050 We need to solve [INAUDIBLE] nonlinear equation to go 1043 01:11:37,050 --> 01:11:39,520 from one step to the next step. 1044 01:11:39,520 --> 01:11:41,850 And what if this is q? 1045 01:11:41,850 --> 01:11:45,200 Then I need to solve a [INAUDIBLE]. 1046 01:11:45,200 --> 01:11:47,018 What is this for? 1047 01:11:47,018 --> 01:11:48,476 I need to solve [INAUDIBLE]. 1048 01:11:51,890 --> 01:11:58,860 What if this is final u times exponential u. 1049 01:11:58,860 --> 01:12:04,860 So this is what we are going to be reading from now to Monday. 1050 01:12:04,860 --> 01:12:07,030 You are going to be reading about one 1051 01:12:07,030 --> 01:12:10,600 of the most important techniques in numerical analysis-- that 1052 01:12:10,600 --> 01:12:13,320 is how to solve a general nonlinear 1053 01:12:13,320 --> 01:12:17,751 equation like this-- something that is even more 1054 01:12:17,751 --> 01:12:20,740 complex than a quadratic equation, 1055 01:12:20,740 --> 01:12:22,950 more complex than cubic equation, something 1056 01:12:22,950 --> 01:12:25,220 that you may not have analytical solutions. 1057 01:12:25,220 --> 01:12:29,270 And it is extremely useful [INAUDIBLE] 1058 01:12:29,270 --> 01:12:34,700 of nonlinear equations, such as [INAUDIBLE] over here. 1059 01:12:34,700 --> 01:12:37,700 So I'll see you on Monday.