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:25,685 --> 00:00:26,560 QIQI WANG: All right. 9 00:00:26,560 --> 00:00:27,320 It's up. 10 00:00:27,320 --> 00:00:31,060 We'll look here and we'll start. 11 00:00:31,060 --> 00:00:35,060 The first real lecture on how to use numerical methods 12 00:00:35,060 --> 00:00:38,190 on partial differential equations. 13 00:00:38,190 --> 00:00:41,630 So just a reminder, of the latter lecture. 14 00:00:41,630 --> 00:00:46,328 We did a-- We looked at partial derivative equations 15 00:00:46,328 --> 00:00:48,770 in general, right? 16 00:00:48,770 --> 00:00:52,750 We looked at the behavior of a few simple differential 17 00:00:52,750 --> 00:00:55,490 equations, where we know how it behaves. 18 00:00:55,490 --> 00:00:59,910 We looked at [INAUDIBLE] equations, 19 00:00:59,910 --> 00:01:03,580 where the solution just keeps moving towards the right. 20 00:01:06,730 --> 00:01:08,670 We looked at a diffusion equation, 21 00:01:08,670 --> 00:01:11,240 where the solution [INAUDIBLE] diffuse result. 22 00:01:11,240 --> 00:01:13,880 It becomes that line afterwards. 23 00:01:13,880 --> 00:01:17,430 We also looked at Burgers' equation, 24 00:01:17,430 --> 00:01:21,640 which is the equation that can generate shock waves. 25 00:01:21,640 --> 00:01:25,740 Where the characteristics can go together 26 00:01:25,740 --> 00:01:27,170 they generate shock waves. 27 00:01:27,170 --> 00:01:29,900 When they become, or when they diverge from each other 28 00:01:29,900 --> 00:01:32,170 they expand, or the solution expands. 29 00:01:32,170 --> 00:01:38,870 And the wave will use a little bit of human kind of animation 30 00:01:38,870 --> 00:01:43,172 to really animate the solution of the partial differential 31 00:01:43,172 --> 00:01:45,150 equation. 32 00:01:45,150 --> 00:01:49,620 So this is a good inclusion on the innovative behavior 33 00:01:49,620 --> 00:01:51,240 of the differential equation. 34 00:01:51,240 --> 00:01:55,810 And so try to remember to us, because in this class, 35 00:01:55,810 --> 00:01:58,970 we are going to be using finite difference to solve them. 36 00:01:58,970 --> 00:02:02,780 And I'm going to ask you where the solution 37 00:02:02,780 --> 00:02:05,415 and body on the screen is correct or not. 38 00:02:05,415 --> 00:02:06,790 I mean, not all of them are going 39 00:02:06,790 --> 00:02:09,334 to be giving us the right answer, as you already 40 00:02:09,334 --> 00:02:12,420 saw in the audio section. 41 00:02:12,420 --> 00:02:16,682 And some of them are going to give me, in this case, answers 42 00:02:16,682 --> 00:02:18,520 that are correct in some parts. 43 00:02:18,520 --> 00:02:20,770 But not really correct in other parts. 44 00:02:20,770 --> 00:02:23,360 And I also ask you, like which part is correct, 45 00:02:23,360 --> 00:02:24,820 which part is not correct? 46 00:02:24,820 --> 00:02:28,390 OK, so let's first start with a finite difference 47 00:02:28,390 --> 00:02:29,520 approximation. 48 00:02:29,520 --> 00:02:32,980 In this case with partial derivatives. 49 00:02:32,980 --> 00:02:36,480 So let's look at the simple case where my solution 50 00:02:36,480 --> 00:02:39,278 U is a function of (x, t). 51 00:02:39,278 --> 00:02:40,652 What are the partial derivatives? 52 00:02:44,552 --> 00:02:45,760 What is a partial derivative? 53 00:02:48,790 --> 00:02:51,910 Du, dx and du, dt. 54 00:02:51,910 --> 00:02:53,020 Right? 55 00:02:53,020 --> 00:02:55,040 Why do we call it a partial derivative? 56 00:02:55,040 --> 00:02:58,530 Because when we are taking derivative of one variable, 57 00:02:58,530 --> 00:03:03,200 we are holding the other one fixed. 58 00:03:03,200 --> 00:03:06,140 So in finite difference method, a good way 59 00:03:06,140 --> 00:03:09,740 to construct the grid to say is I 60 00:03:09,740 --> 00:03:11,990 think it's the first time we look at the grid. 61 00:03:11,990 --> 00:03:14,440 Is to actually construct the grid first 62 00:03:14,440 --> 00:03:18,240 that, it is aligned with one of the variables. 63 00:03:18,240 --> 00:03:20,380 So that, if you look at a particular direction 64 00:03:20,380 --> 00:03:24,990 on the grid, one of the variables are naturally fixed. 65 00:03:24,990 --> 00:03:28,110 So we use in the last naturally, if you remember, 66 00:03:28,110 --> 00:03:32,580 we used these two axes, x and t, to visualize the solution. 67 00:03:32,580 --> 00:03:33,450 Right? 68 00:03:33,450 --> 00:03:36,380 Now let's use the same plot in one direction 69 00:03:36,380 --> 00:03:40,860 x, the other direction t, to visualize my mesh. 70 00:03:40,860 --> 00:03:45,770 I'm going to design my grid or mesh to be like this. 71 00:03:45,770 --> 00:03:47,990 I think in finite difference it's 72 00:03:47,990 --> 00:03:50,250 more common to use the word grid. 73 00:03:50,250 --> 00:03:53,610 And the way you go to find a volume or finite element, 74 00:03:53,610 --> 00:03:55,860 we will use the mesh instead. 75 00:03:55,860 --> 00:03:58,080 And you're going to see why that is the case. 76 00:03:58,080 --> 00:03:59,844 So we have a grid like this. 77 00:04:04,290 --> 00:04:10,440 And you see that I'm describing both space and time separately. 78 00:04:10,440 --> 00:04:10,940 OK? 79 00:04:10,940 --> 00:04:14,880 I'm going to call this-- this x is called a zero. 80 00:04:14,880 --> 00:04:20,339 This is delta x, 2 delta x, 3 delta x, 4 delta x. 81 00:04:20,339 --> 00:04:21,750 Et cetera. 82 00:04:21,750 --> 00:04:27,760 And my timestamp is 0 delta t, 2 delta t, 3 delta t, et cetera. 83 00:04:27,760 --> 00:04:29,270 Right? 84 00:04:29,270 --> 00:04:34,210 So-- I have my solution right here on this grid. 85 00:04:34,210 --> 00:04:39,260 And for example here, my space is equal 86 00:04:39,260 --> 00:04:43,350 to-- I'm also going to assign my grid points. 87 00:04:43,350 --> 00:04:48,790 So this is what I call u of 4. 88 00:04:48,790 --> 00:04:52,450 And one, two, three, four, five. 89 00:04:52,450 --> 00:04:54,070 So remember this notation. 90 00:04:54,070 --> 00:04:59,368 My subscript, you know, the spatial grid, 91 00:04:59,368 --> 00:05:05,130 and my superscript 5 denotes which timestamp I mark. 92 00:05:05,130 --> 00:05:07,800 And here would be U of 4, 4. 93 00:05:07,800 --> 00:05:10,620 Here would be U of 3, 5, et cetera. 94 00:05:15,020 --> 00:05:15,640 OK. 95 00:05:15,640 --> 00:05:19,440 So now I have the solution. 96 00:05:19,440 --> 00:05:23,870 I have the discretized solution leaving all these grid points. 97 00:05:23,870 --> 00:05:27,450 How do I approximate the spatial derivative 98 00:05:27,450 --> 00:05:33,371 of x at some grid point i, and some timestamp n? 99 00:05:33,371 --> 00:05:35,140 Any suggestions based on What you 100 00:05:35,140 --> 00:05:39,590 learned being finite in ODE? 101 00:05:43,360 --> 00:05:44,640 Taylor series, yes. 102 00:05:44,640 --> 00:05:47,367 But can somebody give me a suggestion 103 00:05:47,367 --> 00:05:49,140 of what should I use? 104 00:05:51,875 --> 00:05:52,865 STUDENT: [INAUDIBLE]. 105 00:06:08,210 --> 00:06:11,186 QIQI WANG: 1 delta x further towards the left or right? 106 00:06:11,186 --> 00:06:14,090 STUDENT: [INAUDIBLE]. 107 00:06:14,090 --> 00:06:16,420 QIQI WANG: OK, let's try to use the right. 108 00:06:16,420 --> 00:06:21,070 OK so I can-- nope. 109 00:06:23,770 --> 00:06:27,830 I can approximate the partial derivative by-- in this case, 110 00:06:27,830 --> 00:06:29,730 I'm fixing n, right? 111 00:06:29,730 --> 00:06:32,350 In partial derivatives, I fix the other variable. 112 00:06:32,350 --> 00:06:36,010 In this case, I fixed n, which is the same as fixing t. 113 00:06:36,010 --> 00:06:39,080 I took the difference in the x direction and the i direction, 114 00:06:39,080 --> 00:06:41,750 which is also in the x direction. 115 00:06:41,750 --> 00:06:47,390 So this is an approximation of the derivative in x. 116 00:06:47,390 --> 00:06:52,310 I can call this forward in space. 117 00:06:55,990 --> 00:06:56,490 OK. 118 00:06:56,490 --> 00:06:59,288 I can also-- let me see. 119 00:06:59,288 --> 00:07:01,678 I'm going to insert page. 120 00:07:01,678 --> 00:07:09,728 Escape it turns out I want smaller than A4. 121 00:07:09,728 --> 00:07:12,188 Come on. 122 00:07:12,188 --> 00:07:16,920 I think this is good, OK. 123 00:07:16,920 --> 00:07:19,870 I can also do backward in space. 124 00:07:19,870 --> 00:07:26,690 Backward in space, I would get Uin minus Ui-1n over delta x. 125 00:07:26,690 --> 00:07:32,100 So this is backward in space. 126 00:07:32,100 --> 00:07:36,390 When you see it as-- forward order and backward order 127 00:07:36,390 --> 00:07:39,260 have different stability properties-- 128 00:07:39,260 --> 00:07:43,350 this is also going to have different stability properties. 129 00:07:43,350 --> 00:07:47,380 And I can also do central difference. 130 00:07:47,380 --> 00:07:51,555 So central difference would be U of i 131 00:07:51,555 --> 00:07:54,320 plus 1-- that is towards the right-- minus U 132 00:07:54,320 --> 00:07:58,020 of i-1-- towards the left-- divided by how much? 133 00:07:58,020 --> 00:07:58,724 STUDENT: 2. 134 00:07:58,724 --> 00:08:00,140 QIQI WANG: 2 delta x, because that 135 00:08:00,140 --> 00:08:01,990 is the space in-between them. 136 00:08:01,990 --> 00:08:07,390 So this is central in space. 137 00:08:07,390 --> 00:08:08,370 How about time? 138 00:08:08,370 --> 00:08:11,560 We also need to discretize time. 139 00:08:11,560 --> 00:08:18,458 We also need to discretize partial U partial t at i and n. 140 00:08:18,458 --> 00:08:21,675 How do I approximate that? 141 00:08:21,675 --> 00:08:24,050 STUDENT: [INAUDIBLE]? 142 00:08:24,050 --> 00:08:28,220 QIQI WANG: Exactly the same way as we did in ODEs. 143 00:08:28,220 --> 00:08:35,080 And we can approximate it as U of i n plus 1 minus U of i 144 00:08:35,080 --> 00:08:39,260 n, divided by delta t. 145 00:08:39,260 --> 00:08:46,960 And that could fall into what scheme we use in ODEs? 146 00:08:46,960 --> 00:08:52,740 This grid is going to forward Euler, 147 00:08:52,740 --> 00:08:57,340 and we are going to see later what other things we can use. 148 00:08:57,340 --> 00:09:06,890 So let's try to implement one of the combinations. 149 00:09:06,890 --> 00:09:10,840 So which one-- [INAUDIBLE] because that's 150 00:09:10,840 --> 00:09:14,370 really the simplest type of [INAUDIBLE] scheme, I think. 151 00:09:14,370 --> 00:09:17,604 And you want both or one of these? 152 00:09:17,604 --> 00:09:19,032 STUDENT: [INAUDIBLE]? 153 00:09:19,032 --> 00:09:19,984 QIQI WANG: Huh? 154 00:09:19,984 --> 00:09:21,214 STUDENT: [INAUDIBLE]. 155 00:09:21,214 --> 00:09:21,880 QIQI WANG: What? 156 00:09:21,880 --> 00:09:22,800 STUDENT: Central in space one. 157 00:09:22,800 --> 00:09:24,180 QIQI WANG: Central in space one. 158 00:09:24,180 --> 00:09:25,770 All right, good. 159 00:09:25,770 --> 00:09:29,803 Because you guys probably can do Taylor Series in your head 160 00:09:29,803 --> 00:09:31,710 and figure out the central difference 161 00:09:31,710 --> 00:09:33,870 is actually second-order accurate. 162 00:09:33,870 --> 00:09:36,300 It is better than the other two. 163 00:09:36,300 --> 00:09:37,480 So good. 164 00:09:37,480 --> 00:09:39,420 You have a good pick. 165 00:09:39,420 --> 00:09:43,450 OK, so I'm going to go to Matlab. 166 00:09:43,450 --> 00:09:46,510 The first thing I want to show you in Matlab 167 00:09:46,510 --> 00:09:51,370 is-- let me show you in the next class what 168 00:09:51,370 --> 00:09:53,910 the difference between finite difference and finite volume. 169 00:09:53,910 --> 00:09:56,160 But I'm just going to show really 170 00:09:56,160 --> 00:10:02,410 kind of how a finite different discretize a function. 171 00:10:02,410 --> 00:10:05,490 So when we have a function in space, 172 00:10:05,490 --> 00:10:07,457 we have to discretize it, right? 173 00:10:07,457 --> 00:10:09,790 So, because the function is really infinite-dimensional, 174 00:10:09,790 --> 00:10:12,260 we only have finite memory. 175 00:10:12,260 --> 00:10:14,720 So if you draw a function like this, 176 00:10:14,720 --> 00:10:19,160 a finite difference only stores the values on the grid points. 177 00:10:19,160 --> 00:10:21,690 So the red circles are what it stores. 178 00:10:21,690 --> 00:10:26,170 What is in the middle are just forgotten by the computer. 179 00:10:26,170 --> 00:10:28,800 And all the derivatives have to be approximated 180 00:10:28,800 --> 00:10:31,730 by these discrete points. 181 00:10:31,730 --> 00:10:35,340 And this now seems natural to you for sure. 182 00:10:35,340 --> 00:10:37,060 But, as we go to find the volume, 183 00:10:37,060 --> 00:10:40,230 you are going to see how different discretization 184 00:10:40,230 --> 00:10:44,520 schemes are going to be discretizing a function. 185 00:10:44,520 --> 00:10:49,310 OK so let's try to implement a central difference plus forward 186 00:10:49,310 --> 00:10:53,020 Euler on the advection equation. 187 00:10:53,020 --> 00:10:55,370 So I haven't said what equation I'm going to do yet. 188 00:10:55,370 --> 00:10:58,880 So I'm going to implement it on this equation. 189 00:10:58,880 --> 00:11:06,730 Partial U partial t plus partial U partial x is equal to zero. 190 00:11:06,730 --> 00:11:09,576 With a periodic boundary condition, 191 00:11:09,576 --> 00:11:15,640 you add 0 is equal to U at 1. 192 00:11:15,640 --> 00:11:21,040 So this is a periodic boundary condition. 193 00:11:21,040 --> 00:11:23,300 So this is the same equation as we 194 00:11:23,300 --> 00:11:25,130 tried to animate last Thursday. 195 00:11:25,130 --> 00:11:28,820 Anybody who goes out of these doors comes back from inside 196 00:11:28,820 --> 00:11:30,060 here. 197 00:11:30,060 --> 00:11:33,920 So we should be seeing-- this is the linear advection equation. 198 00:11:33,920 --> 00:11:37,910 And all the characteristic lines are parallel. 199 00:11:37,910 --> 00:11:40,966 The characteristic lines are like the colorful lines 200 00:11:40,966 --> 00:11:42,630 in the solution in the x and t diagram. 201 00:11:45,400 --> 00:11:52,860 So all the characteristic points go towards the right, 202 00:11:52,860 --> 00:11:56,458 and along each characteristic line, the solution is constant. 203 00:11:59,710 --> 00:12:03,620 So let's try to implement the forward order 204 00:12:03,620 --> 00:12:06,560 central difference and see how the solution looks 205 00:12:06,560 --> 00:12:10,600 like numerically. 206 00:12:10,600 --> 00:12:14,470 So I'm going to New file to Script. 207 00:12:14,470 --> 00:12:21,710 So central space, forward time. 208 00:12:21,710 --> 00:12:24,370 So this is my central space, forward time. 209 00:12:24,370 --> 00:12:26,760 I'm going to set up my number of grid points. 210 00:12:26,760 --> 00:12:29,745 Let's just use 100 grid points in space. 211 00:12:33,270 --> 00:12:38,870 And because I have a domain from 0 to 1, 212 00:12:38,870 --> 00:12:43,450 my delta x is equal to 1 divided by n. 213 00:12:43,450 --> 00:12:46,840 So this is my delta x. 214 00:12:46,840 --> 00:12:49,770 Let me choose the initial solution that looks somewhat 215 00:12:49,770 --> 00:12:51,320 like Gaussian. 216 00:12:51,320 --> 00:12:55,520 OK, so we have a peak, and we see how the peak evolves. 217 00:12:55,520 --> 00:13:02,350 So let me, first of all, set my x equal to 1:N times my dx. 218 00:13:02,350 --> 00:13:06,750 So I have a grid, and accessed the spacial location 219 00:13:06,750 --> 00:13:08,880 of the grid. 220 00:13:08,880 --> 00:13:12,900 And let's set my u0 my initial condition, 221 00:13:12,900 --> 00:13:24,360 to be exponential of minus x minus 0.5 squared, divided 222 00:13:24,360 --> 00:13:27,550 by 0.1 squared. 223 00:13:27,550 --> 00:13:30,910 And I have to do this divide. 224 00:13:30,910 --> 00:13:33,620 So we can take a look at how the solution looks like. 225 00:13:33,620 --> 00:13:35,460 We can plot x and u0. 226 00:13:35,460 --> 00:13:37,210 And we are going to run the script 227 00:13:37,210 --> 00:13:39,110 to see how the solution looks like. 228 00:13:39,110 --> 00:13:41,010 So this is the initial condition. 229 00:13:41,010 --> 00:13:44,341 We have a Gaussian curve. 230 00:13:44,341 --> 00:13:47,540 The shape of the curve is exponential. 231 00:13:47,540 --> 00:13:50,447 1 minus x minus 0.5. 232 00:13:50,447 --> 00:13:53,980 So 0.5 is the central of the Gaussian. 233 00:13:53,980 --> 00:13:57,170 And the reason [INAUDIBLE] standard deviation 234 00:13:57,170 --> 00:14:00,280 can be plus 1, [INAUDIBLE]. 235 00:14:00,280 --> 00:14:04,610 The width of the Gaussian or half-width of the Gaussian. 236 00:14:04,610 --> 00:14:07,740 Any questions on this? 237 00:14:07,740 --> 00:14:10,010 No? 238 00:14:10,010 --> 00:14:11,480 OK. 239 00:14:11,480 --> 00:14:15,940 So let's decide on a timestamp. 240 00:14:15,940 --> 00:14:19,042 What do you guys want on the timestamp? 241 00:14:22,858 --> 00:14:23,789 0.1? 242 00:14:23,789 --> 00:14:24,289 All right. 243 00:14:28,250 --> 00:14:32,290 I goes from 1 to 1/dt. 244 00:14:32,290 --> 00:14:35,400 So let's simulate it for one time unit, 245 00:14:35,400 --> 00:14:39,900 because after one time unit, the speed of the solution going 246 00:14:39,900 --> 00:14:43,680 towards the right is 1. 247 00:14:43,680 --> 00:14:46,210 That is because in my equation, I 248 00:14:46,210 --> 00:14:53,920 put if there should be a small c, then this c is equal to 1. 249 00:14:53,920 --> 00:14:56,290 So my speed of the solution going towards the right 250 00:14:56,290 --> 00:14:57,250 is equal to 1. 251 00:14:57,250 --> 00:14:59,050 So after one time unit, the solution 252 00:14:59,050 --> 00:15:02,930 should go through the domain once and end up exactly 253 00:15:02,930 --> 00:15:05,543 at the same location as the initial condition. 254 00:15:08,680 --> 00:15:14,380 Now when I'm doing forward order, plus central difference, 255 00:15:14,380 --> 00:15:21,310 I need to first compute the dU/dx at each grid location. 256 00:15:21,310 --> 00:15:24,390 And dU/dx, at each grid location, 257 00:15:24,390 --> 00:15:26,290 is the difference between the solution 258 00:15:26,290 --> 00:15:29,950 towards the right minus the solution towards the left, 259 00:15:29,950 --> 00:15:31,620 divided by 2 delta x. 260 00:15:31,620 --> 00:15:35,640 And look carefully at how I'm computing the solution 261 00:15:35,640 --> 00:15:37,840 on the right and on the left. 262 00:15:37,840 --> 00:15:42,740 du dx is equal to-- what I'm going 263 00:15:42,740 --> 00:15:50,920 to do is I'm going to do circshift of my u0, of my u. 264 00:15:50,920 --> 00:15:55,255 I'm first going to say u is equal to u0. 265 00:15:55,255 --> 00:15:56,470 [INAUDIBLE] 266 00:15:56,470 --> 00:15:59,340 I am going to do circshift of u, and I'm 267 00:15:59,340 --> 00:16:04,570 going to be shifting 0 on the first dimension and a -1 268 00:16:04,570 --> 00:16:07,620 on the second dimension. 269 00:16:07,620 --> 00:16:11,410 So does this give me? 270 00:16:11,410 --> 00:16:14,660 I'm going to go back to Matlab and tell you what it gives us. 271 00:16:14,660 --> 00:16:20,020 So if I do 1 to 10, for example, I'm 272 00:16:20,020 --> 00:16:24,100 going to get an array going from 1 to 10. 273 00:16:24,100 --> 00:16:28,640 If I do circshift of 1 to 10, I'm 274 00:16:28,640 --> 00:16:32,320 going to shift it-- I'll put 0 in the first dimension and 1 275 00:16:32,320 --> 00:16:33,650 on the first dimension. 276 00:16:33,650 --> 00:16:35,990 This is what I'm going to get. 277 00:16:35,990 --> 00:16:41,566 I'm circularly picking these 1 to 10, towards the right. 278 00:16:41,566 --> 00:16:43,620 So instead of 1 here, I get [INAUDIBLE], 279 00:16:43,620 --> 00:16:46,680 which is why this method-- the [INAUDIBLE] method-- comes out 280 00:16:46,680 --> 00:16:49,870 of the [INAUDIBLE] and goes here. 281 00:16:49,870 --> 00:16:53,500 And the [INAUDIBLE] is that [INAUDIBLE] here. 282 00:16:53,500 --> 00:16:56,050 Everybody's shifted towards the right 1. 283 00:16:58,710 --> 00:17:07,020 Now if I want to grab the i plus 1 person at the i place, 284 00:17:07,020 --> 00:17:11,849 this is the opposite of what I need to do. 285 00:17:11,849 --> 00:17:14,150 What I need to do is I need to put -1 286 00:17:14,150 --> 00:17:17,319 here so that at the first place, I'm 287 00:17:17,319 --> 00:17:20,610 going to be grabbing the next solution and the next grid 288 00:17:20,610 --> 00:17:22,530 point. 289 00:17:22,530 --> 00:17:25,619 And particularly at the last grid point 290 00:17:25,619 --> 00:17:30,140 I'm grabbing the solution [INAUDIBLE], 291 00:17:30,140 --> 00:17:32,130 which is actually the other way you're 292 00:17:32,130 --> 00:17:36,085 supposed to do it on the left [INAUDIBLE], which is 1. 293 00:17:36,085 --> 00:17:40,750 So this is the way you can [INAUDIBLE] Ui plus 1. 294 00:17:40,750 --> 00:17:44,600 If you have periodic [INAUDIBLE]. 295 00:17:44,600 --> 00:17:46,660 What about Ui minus 1? 296 00:17:49,420 --> 00:17:51,052 This is my Ui minus 1. 297 00:17:51,052 --> 00:17:52,528 This is my Ui-1. 298 00:17:56,464 --> 00:18:00,400 Any questions on that? 299 00:18:00,400 --> 00:18:03,844 Someone said it back there? 300 00:18:03,844 --> 00:18:04,828 STUDENT: [INAUDIBLE]? 301 00:18:08,590 --> 00:18:09,256 QIQI WANG: Yeah. 302 00:18:09,256 --> 00:18:14,690 On this one, things are being rotated towards the left. 303 00:18:14,690 --> 00:18:19,276 The 1 which is here now was the end. 304 00:18:19,276 --> 00:18:23,480 And the 2 [INAUDIBLE] here now is here. 305 00:18:23,480 --> 00:18:25,356 3 was here, here. 306 00:18:29,110 --> 00:18:29,839 Yes? 307 00:18:29,839 --> 00:18:30,817 STUDENT: [INAUDIBLE]? 308 00:18:41,575 --> 00:18:47,000 QIQI WANG: So in the ODE part, why didn't we do a circshift? 309 00:18:47,000 --> 00:18:48,480 The answer is in the ODE part, we 310 00:18:48,480 --> 00:18:51,220 didn't do a circshift, because we 311 00:18:51,220 --> 00:18:53,540 don't have the solution at ndx. 312 00:18:53,540 --> 00:18:56,070 So when we are at the end timestamp, 313 00:18:56,070 --> 00:19:00,290 we don't have the solution at the n plus 1 timestamp. 314 00:19:00,290 --> 00:19:06,470 While in the PV part, we have a grid like this, 315 00:19:06,470 --> 00:19:09,330 and we are given the whole initial conditions. 316 00:19:09,330 --> 00:19:12,250 So I've given the whole initial condition at [? p ?] 317 00:19:12,250 --> 00:19:13,780 equal to 0. 318 00:19:13,780 --> 00:19:17,110 So we have all the data at this timestamp. 319 00:19:17,110 --> 00:19:20,652 Now our job is to go from this timestamp to this timestamp. 320 00:19:20,652 --> 00:19:23,720 We want to compute from the solution here 321 00:19:23,720 --> 00:19:26,170 all the solutions on these grid points. 322 00:19:26,170 --> 00:19:30,700 And then we go forward and forward and forward. 323 00:19:30,700 --> 00:19:33,930 So there is a fundamental difference 324 00:19:33,930 --> 00:19:37,300 between space and time. 325 00:19:37,300 --> 00:19:40,100 In time, you don't know what is going 326 00:19:40,100 --> 00:19:42,580 to happen tomorrow, right? 327 00:19:42,580 --> 00:19:46,990 In space, we have access to the solution 328 00:19:46,990 --> 00:19:48,792 at all the spatial locations. 329 00:19:48,792 --> 00:19:52,153 At the current timestamp, and if you stored 330 00:19:52,153 --> 00:19:54,839 the past timestamps, also at the past 331 00:19:54,839 --> 00:19:56,505 timestamps so you know all these things. 332 00:19:59,900 --> 00:20:03,830 So that's the difference between space and time. 333 00:20:03,830 --> 00:20:08,190 Although, doing Taylor series analyses on them are the same. 334 00:20:08,190 --> 00:20:10,720 But in terms of coding, they are different. 335 00:20:10,720 --> 00:20:12,590 In terms of the order of computation, 336 00:20:12,590 --> 00:20:13,658 they are different. 337 00:20:17,470 --> 00:20:19,455 So going back to our Matlab code, 338 00:20:19,455 --> 00:20:22,360 we shift towards the -1 direction 339 00:20:22,360 --> 00:20:26,040 that is grabbing Ui plus 1. 340 00:20:26,040 --> 00:20:28,600 If we shift the whole thing towards the positive 1 341 00:20:28,600 --> 00:20:31,660 direction, we are grabbing ui. 342 00:20:31,660 --> 00:20:37,060 And if we divide that by 2dx, we are computing du dx, right? 343 00:20:40,750 --> 00:20:44,940 So now we have du dx, we want to plug this into this equation. 344 00:20:48,066 --> 00:20:54,460 dU/dt, in this case, is equal to minus of du dx. 345 00:20:54,460 --> 00:20:56,550 This is what this equation is. 346 00:20:56,550 --> 00:20:59,130 If you shift du dx towards the right-hand side, 347 00:20:59,130 --> 00:21:03,484 du dt would be minus of du dx. 348 00:21:03,484 --> 00:21:04,900 So that's what we are going to do. 349 00:21:04,900 --> 00:21:11,160 du dt is equal to minus du dx We used the partial differential 350 00:21:11,160 --> 00:21:16,490 equation to convert a spatial derivative into a time 351 00:21:16,490 --> 00:21:16,990 derivative. 352 00:21:16,990 --> 00:21:20,090 This is the result of using the partial differential equation. 353 00:21:24,294 --> 00:21:26,460 So the first step, find the difference approximation 354 00:21:26,460 --> 00:21:31,094 of the spatial derivative, the partial derivative of x. 355 00:21:31,094 --> 00:21:35,140 Use the differential equation to get the time derivative. 356 00:21:35,140 --> 00:21:38,403 And anybody want to suggest what is next? 357 00:21:43,500 --> 00:21:46,650 Are we back into the ODE world? 358 00:21:46,650 --> 00:21:49,430 We are back into the ODE world. 359 00:21:49,430 --> 00:21:53,060 We have computed the time derivative of the solution 360 00:21:53,060 --> 00:21:57,740 at all the grid points we had. 361 00:21:57,740 --> 00:21:59,530 We can use forward order. 362 00:22:02,296 --> 00:22:05,700 From the cutoff, we can use [INAUDIBLE] 363 00:22:05,700 --> 00:22:12,030 or other sexy things we learned in the ODE section. 364 00:22:12,030 --> 00:22:17,220 So let's do the most elementary thing and apply forward order. 365 00:22:17,220 --> 00:22:22,420 u is going to equal u plus dt times du dt. 366 00:22:22,420 --> 00:22:27,348 This is exactly how you implement forward order in ODE. 367 00:22:30,600 --> 00:22:33,679 So we already plotted the solution 368 00:22:33,679 --> 00:22:34,720 at the initial condition. 369 00:22:34,720 --> 00:22:37,320 Let's also hold on so that we don't 370 00:22:37,320 --> 00:22:39,230 lose the plot of the initial condition 371 00:22:39,230 --> 00:22:43,502 and also plot my x and u at t equal to 1. 372 00:22:43,502 --> 00:22:47,520 And let's see how the solution will look like. 373 00:22:47,520 --> 00:22:49,327 And let's actually plot this in red, 374 00:22:49,327 --> 00:22:50,910 because the initial condition is going 375 00:22:50,910 --> 00:22:54,110 to be-- let's plot the initial condition black 376 00:22:54,110 --> 00:22:57,020 and the solution red and see how it looks like. 377 00:23:00,359 --> 00:23:04,420 We get a pretty big solution. 378 00:23:07,580 --> 00:23:10,740 This may not be the fault of spatial derivatives, 379 00:23:10,740 --> 00:23:14,660 though, because we know forward order has a pretty 380 00:23:14,660 --> 00:23:17,330 limited stability region. 381 00:23:17,330 --> 00:23:21,250 But we know forward order is 0 stable. 382 00:23:21,250 --> 00:23:23,670 Which means what? 383 00:23:23,670 --> 00:23:27,180 Which means there it is always going to shrink the timestamp. 384 00:23:27,180 --> 00:23:28,980 Which means it is globally accurate. 385 00:23:28,980 --> 00:23:33,300 And global accuracy means when you make the timestamp smaller, 386 00:23:33,300 --> 00:23:37,170 the solution of the ODE at least converges to the [INAUDIBLE] 387 00:23:37,170 --> 00:23:38,150 solution of the ODE. 388 00:23:38,150 --> 00:23:40,510 So let's see if it helps in this case. 389 00:23:40,510 --> 00:23:46,220 Let's make delta t equal to 0.001, and let's run it again. 390 00:23:46,220 --> 00:23:49,264 Let me close all before I do the plot. 391 00:23:55,048 --> 00:23:59,870 This time, we get pretty good. 392 00:23:59,870 --> 00:24:05,862 We do see the solution having a pretty good match 393 00:24:05,862 --> 00:24:07,070 with the analytical solution. 394 00:24:07,070 --> 00:24:10,765 And let's also visualize how this thing progesses. 395 00:24:10,765 --> 00:24:16,205 For every timestamp, let me actually do the plotting. 396 00:24:16,205 --> 00:24:24,640 For every timestamp, let me do the visualization at clf which 397 00:24:24,640 --> 00:24:26,680 means clear the figure. 398 00:24:26,680 --> 00:24:29,140 I'm going to plot the initial condition. 399 00:24:29,140 --> 00:24:31,320 I'm going to hold on. 400 00:24:31,320 --> 00:24:36,980 And I'm going to plot the solution. 401 00:24:41,692 --> 00:24:44,150 So I'm clearing the figure, plotting the initial condition, 402 00:24:44,150 --> 00:24:46,230 plotting the solution. 403 00:24:46,230 --> 00:24:48,570 And then you could do draw now. 404 00:24:48,570 --> 00:24:50,940 So let's take a look at how-- let me actually 405 00:24:50,940 --> 00:24:52,170 pause for a little bit. 406 00:24:52,170 --> 00:24:55,500 Pause for 0.01 seconds so that we can actually 407 00:24:55,500 --> 00:24:56,626 see the solution moving. 408 00:25:01,820 --> 00:25:09,990 So the red one is my solution as my time goes from 0 to 1. 409 00:25:09,990 --> 00:25:11,540 So does it look like we are capturing 410 00:25:11,540 --> 00:25:13,930 at least the qualitative behavior 411 00:25:13,930 --> 00:25:19,070 of the analytical solution? 412 00:25:19,070 --> 00:25:21,490 Yes. 413 00:25:21,490 --> 00:25:24,226 Although, it is not completely satisfactory, 414 00:25:24,226 --> 00:25:28,960 because [INAUDIBLE] and the solution 415 00:25:28,960 --> 00:25:32,373 seems to be growing a little bit. 416 00:25:32,373 --> 00:25:33,295 STUDENT: [INAUDIBLE]. 417 00:25:38,200 --> 00:25:42,064 QIQI WANG: And also, another concerning point you have 418 00:25:42,064 --> 00:25:48,024 [INAUDIBLE] is that the solution initially was all positive. 419 00:25:48,024 --> 00:25:50,430 And you can look at my analytical graphing 420 00:25:50,430 --> 00:25:53,784 for the initial condition where [INAUDIBLE] quantity. 421 00:25:53,784 --> 00:25:55,200 It's the exponential of something. 422 00:25:55,200 --> 00:25:57,767 How can it not be positive? 423 00:25:57,767 --> 00:26:01,190 But, like [INAUDIBLE], it becomes negative at some point. 424 00:26:01,190 --> 00:26:05,690 So it overshoots and undershoots. 425 00:26:05,690 --> 00:26:08,870 I mean, we're not going to discuss this today. 426 00:26:08,870 --> 00:26:16,830 But we're going to be discussing the reason of this error, 427 00:26:16,830 --> 00:26:19,900 both on Wednesday-- Professor Wilcox 428 00:26:19,900 --> 00:26:22,510 is going to teach on Wednesday. 429 00:26:22,510 --> 00:26:30,421 And on the error of this finite difference method. 430 00:26:30,421 --> 00:26:33,330 How to analyze this error and convergence. 431 00:26:33,330 --> 00:26:37,902 And another, very related issue is stability. 432 00:26:37,902 --> 00:26:39,610 That is something we are also going to be 433 00:26:39,610 --> 00:26:42,140 discussing in the PDE section. 434 00:26:42,140 --> 00:26:48,120 But this class, we are just happy we got a solution. 435 00:26:48,120 --> 00:26:50,970 And we can also see that the solution 436 00:26:50,970 --> 00:26:56,630 is going to get better as I make my grid to be finer. 437 00:26:56,630 --> 00:27:00,920 Instead of 100, let's do 200, and we run the same thing. 438 00:27:03,540 --> 00:27:07,010 It's going to get slower, but the rate of growth 439 00:27:07,010 --> 00:27:11,874 is going to be not as severe as in the 100 case. 440 00:27:23,220 --> 00:27:25,682 [INAUDIBLE] 441 00:27:25,682 --> 00:27:31,910 Don't really see the undershooting [INAUDIBLE] 442 00:27:31,910 --> 00:27:35,530 for the [INAUDIBLE] Question? 443 00:27:35,530 --> 00:27:37,498 STUDENT: [INAUDIBLE] questions. 444 00:27:37,498 --> 00:27:45,370 [INAUDIBLE] Why didn't we see the [INAUDIBLE]? 445 00:27:56,262 --> 00:27:56,970 QIQI WANG: Right. 446 00:27:56,970 --> 00:28:01,430 So we did a comparison between-- actually, 447 00:28:01,430 --> 00:28:03,202 let me ask you a question about it first. 448 00:28:03,202 --> 00:28:04,952 So the question is on backward difference, 449 00:28:04,952 --> 00:28:06,490 what's the central difference? 450 00:28:06,490 --> 00:28:08,100 So what do we need to change here 451 00:28:08,100 --> 00:28:09,650 to make it backward difference? 452 00:28:14,148 --> 00:28:16,638 STUDENT: The ability of [INAUDIBLE] 453 00:28:19,860 --> 00:28:22,270 QIQI WANG: First of all, it just needs to be delta 454 00:28:22,270 --> 00:28:25,670 x not 2 delta x. 455 00:28:25,670 --> 00:28:30,360 And instead of ui plus 1 minus ui minus 1, 456 00:28:30,360 --> 00:28:33,260 we have u minus ui minus 1. 457 00:28:33,260 --> 00:28:35,840 So we're just going to be putting u here. 458 00:28:35,840 --> 00:28:38,420 This is going to be backward difference. 459 00:28:38,420 --> 00:28:42,310 And when you run backward difference-- whoa. 460 00:28:42,310 --> 00:28:47,910 Yeah, we get a similar solution, but now 461 00:28:47,910 --> 00:28:49,190 what does the solution do? 462 00:28:49,190 --> 00:28:55,806 Instead of growing a little bit, it decays a little bit. 463 00:28:58,800 --> 00:29:02,390 And we see we have the same number of grid points. 464 00:29:02,390 --> 00:29:04,628 That's where the difference seems 465 00:29:04,628 --> 00:29:08,037 to have more undershoot than overshoot 466 00:29:08,037 --> 00:29:10,959 of the backward difference. 467 00:29:10,959 --> 00:29:14,140 And again, Professor Wilcox is going 468 00:29:14,140 --> 00:29:19,318 to discuss the accuracy of these two methods on Wednesday. 469 00:29:24,420 --> 00:29:30,010 So this is the implementation of the central 470 00:29:30,010 --> 00:29:34,820 in space and backwards in space finite difference scheme. 471 00:29:34,820 --> 00:29:40,810 And we also discussed in the last lecture 472 00:29:40,810 --> 00:29:45,570 how to solve-- what is the behavior of a diffusion 473 00:29:45,570 --> 00:29:49,760 equation when we have diffusion instead of advection. 474 00:29:49,760 --> 00:29:53,070 We have a differential equation that is like this, 475 00:29:53,070 --> 00:29:56,980 partial U partial t is equal to k times partial squared u 476 00:29:56,980 --> 00:29:57,990 partial x squared. 477 00:30:02,740 --> 00:30:06,770 And we can even have a mixed differential equation. 478 00:30:06,770 --> 00:30:09,480 We can have a mix, advection and diffusion. 479 00:30:12,360 --> 00:30:15,177 So how do we approximate this term? 480 00:30:15,177 --> 00:30:17,260 How do we approximate the second order derivative? 481 00:30:22,520 --> 00:30:27,910 Now the second order derivative has a very concise 482 00:30:27,910 --> 00:30:28,700 approximation. 483 00:30:28,700 --> 00:30:32,400 So the second derivative of x at a particular grid 484 00:30:32,400 --> 00:30:37,510 point at a timestamp can be approximated 485 00:30:37,510 --> 00:30:46,508 as this-- as u of i plus 1n minus 2 Ui n plus U of i-1 n. 486 00:30:50,760 --> 00:30:54,710 Divided by delta x squared. 487 00:31:02,060 --> 00:31:04,850 Unlike the first order derivative, 488 00:31:04,850 --> 00:31:10,710 you have the choice of forward and backward difference. 489 00:31:10,710 --> 00:31:13,160 For approximating second order derivatives, 490 00:31:13,160 --> 00:31:17,690 this is the single most popular scheme we use. 491 00:31:17,690 --> 00:31:23,940 And it is very difficult to find an approximation that 492 00:31:23,940 --> 00:31:25,840 is as popular as this. 493 00:31:25,840 --> 00:31:28,960 And let me describe to you why this is the case. 494 00:31:28,960 --> 00:31:33,170 OK We are approximating the second order derivative. 495 00:31:33,170 --> 00:31:39,210 We are only using three points, the center, left, and right. 496 00:31:39,210 --> 00:31:43,560 And amazingly, this thing has second order accuracy, 497 00:31:43,560 --> 00:31:44,905 has very good accuracy. 498 00:31:48,730 --> 00:31:51,710 And you can show that by doing Taylor Series on that-- it's 499 00:31:51,710 --> 00:31:58,050 U of i plus 1 n can be expanded as U of i n plus delta 500 00:31:58,050 --> 00:32:04,580 x times, in this case, the partial derivative of partial U 501 00:32:04,580 --> 00:32:09,730 partial x at i n, plus half of delta x 502 00:32:09,730 --> 00:32:17,710 squared of the second derivative of U at i n. 503 00:32:17,710 --> 00:32:21,050 I'm going to be expanding more terms. 504 00:32:21,050 --> 00:32:24,610 It's the third of the derivative times 505 00:32:24,610 --> 00:32:26,930 delta x cubed divided by 6. 506 00:32:29,610 --> 00:32:36,930 And I'm just going to write over here O delta x to the 4th. 507 00:32:36,930 --> 00:32:40,060 Now this this term. 508 00:32:40,060 --> 00:32:42,840 I am also going to be expanding this term. 509 00:32:42,840 --> 00:32:47,640 Ui-1 of n is equal to Ui n. 510 00:32:47,640 --> 00:32:50,310 In this case, it's minus delta x because the difference 511 00:32:50,310 --> 00:32:53,520 between the i-1th grid point and the i-th grid point 512 00:32:53,520 --> 00:32:54,860 is minus delta x. 513 00:32:57,930 --> 00:33:01,380 The second derivative term is plus again, 514 00:33:01,380 --> 00:33:03,980 because we are taking the square of minus delta x. 515 00:33:08,290 --> 00:33:10,250 The third derivative is minus again, 516 00:33:10,250 --> 00:33:13,850 because we are taking the cube of delta x. 517 00:33:16,870 --> 00:33:19,936 And again, we have plus delta x to the 4th. 518 00:33:26,260 --> 00:33:29,700 Now we can start to see which terms start to cancel out. 519 00:33:32,850 --> 00:33:38,670 See we have one of Ui n here plus another Ui n here. 520 00:33:38,670 --> 00:33:41,580 Now we have minus 2 of Uin. 521 00:33:41,580 --> 00:33:45,070 So this and these cancel together, 522 00:33:45,070 --> 00:33:46,894 cancels with this minus 2Uin. 523 00:33:50,790 --> 00:33:52,145 All right, this is one term. 524 00:33:57,570 --> 00:33:59,280 This and this is added up. 525 00:33:59,280 --> 00:34:01,570 So i plus 1 i minus 1 is added up. 526 00:34:01,570 --> 00:34:03,247 So the first derivative term cancels. 527 00:34:06,990 --> 00:34:09,630 The third derivative term, instead of canceling, 528 00:34:09,630 --> 00:34:10,894 they add up. 529 00:34:10,894 --> 00:34:14,699 So they, divided by delta x squared, 530 00:34:14,699 --> 00:34:17,630 serves as an approximation of partial squared U partial x 531 00:34:17,630 --> 00:34:19,290 squared. 532 00:34:19,290 --> 00:34:22,568 It is a consistent approximation for partial squared U 533 00:34:22,568 --> 00:34:24,989 partial x. 534 00:34:24,989 --> 00:34:27,130 And usually, when you have three terms-- when 535 00:34:27,130 --> 00:34:31,800 you are playing around the coefficient of three neighbors, 536 00:34:31,800 --> 00:34:38,870 you can make sure three terms add up 537 00:34:38,870 --> 00:34:41,269 to what you want it to be. 538 00:34:41,269 --> 00:34:42,810 You've got rid of the constant terms. 539 00:34:42,810 --> 00:34:44,940 You've got rid of the first order derivative terms. 540 00:34:44,940 --> 00:34:48,100 You make sure that the second order derivative turns out 541 00:34:48,100 --> 00:34:50,230 to be what you want to approximate. 542 00:34:50,230 --> 00:34:53,380 But in this case, you get a bonus. 543 00:34:53,380 --> 00:34:57,330 The third order derivative term cancels out too, just 544 00:34:57,330 --> 00:35:00,740 by accident, and now, you only get a delta x 545 00:35:00,740 --> 00:35:04,500 to the 4th, which after dividing by delta x squared, 546 00:35:04,500 --> 00:35:08,380 you get a second-order accurate approximation 547 00:35:08,380 --> 00:35:09,500 to the second derivative. 548 00:35:14,840 --> 00:35:18,790 So the error, which is the actual second order 549 00:35:18,790 --> 00:35:28,690 derivative minus the finite difference approximation 550 00:35:28,690 --> 00:35:33,550 goes like O delta x squared. 551 00:35:33,550 --> 00:35:36,940 And this is pure luckiness. 552 00:35:40,680 --> 00:35:43,100 Any questions on this? 553 00:35:43,100 --> 00:35:47,870 This scheme is what we are going to be using. 554 00:35:57,090 --> 00:36:01,315 Now let's go back and modify our code 555 00:36:01,315 --> 00:36:05,020 to also do second order derivatives. 556 00:36:05,020 --> 00:36:07,430 So we have du dx. 557 00:36:07,430 --> 00:36:13,810 We have d2udx2 equal to-- let me copy this. 558 00:36:13,810 --> 00:36:19,680 And we have a Ui plus 1, which is circshift of U 559 00:36:19,680 --> 00:36:22,330 towards or the minus direction. 560 00:36:22,330 --> 00:36:30,500 We minus 2 times u and plus u of i minus 1. 561 00:36:30,500 --> 00:36:34,190 And divide it by delta x squared. 562 00:36:34,190 --> 00:36:38,160 So this is our second order derivative. 563 00:36:38,160 --> 00:36:42,220 If we want to solve the diffusion equation over here, 564 00:36:42,220 --> 00:36:44,720 the du dt would instead of being minus du 565 00:36:44,720 --> 00:36:48,145 dx we have the positive of d2udx2. 566 00:36:51,670 --> 00:36:55,800 And let's put a cover here, a 0.1 567 00:36:55,800 --> 00:36:58,380 cover so that it diffuses slower. 568 00:36:58,380 --> 00:37:02,450 And then let's look at how the numerical solution looks like. 569 00:37:02,450 --> 00:37:08,060 Let's change back to 100. 570 00:37:08,060 --> 00:37:09,615 Oops. 571 00:37:09,615 --> 00:37:12,860 Again, if the stability is coming up, 572 00:37:12,860 --> 00:37:15,830 let me make sure we have a small enough timestamp. 573 00:37:19,560 --> 00:37:25,450 So we can see are the solution of this PDE 574 00:37:25,450 --> 00:37:29,310 agrees with the analytical behavior of the PDE, 575 00:37:29,310 --> 00:37:31,620 which is the solution diffuses out. 576 00:37:31,620 --> 00:37:34,800 It becomes less sharp. 577 00:37:34,800 --> 00:37:36,970 And we can even combine these two terms. 578 00:37:36,970 --> 00:37:42,370 We can du dx plus this, or we can do a convection diffusion 579 00:37:42,370 --> 00:37:42,870 equation. 580 00:37:46,510 --> 00:37:50,216 And we can see the solution diffuses 581 00:37:50,216 --> 00:37:55,570 and also, in this case, it's shifting towards the left, 582 00:37:55,570 --> 00:37:59,060 because I think that the right convection-diffusion equation 583 00:37:59,060 --> 00:38:01,920 should be minus du dx. 584 00:38:01,920 --> 00:38:04,640 Let me make sure that is the case. 585 00:38:04,640 --> 00:38:08,690 So we have a solution that is diffusion by the diffusion 586 00:38:08,690 --> 00:38:13,120 terms, and also advects toward light by this advection. 587 00:38:24,290 --> 00:38:27,900 Now let's take just a 5 minute break before we 588 00:38:27,900 --> 00:38:30,240 go to the matrix form. 589 00:38:30,240 --> 00:38:32,830 We did find a difference [INAUDIBLE]. 590 00:38:32,830 --> 00:38:35,730 Before we go into the matrix form of this finite difference 591 00:38:35,730 --> 00:38:39,600 method-- and we see the matrix form is going to come up a lot, 592 00:38:39,600 --> 00:38:43,450 and it's going to be very useful in, for example, 593 00:38:43,450 --> 00:38:48,200 in physics scemes of finite difference methods. 594 00:38:48,200 --> 00:38:48,700 All right. 595 00:38:48,700 --> 00:38:49,200 OK. 596 00:38:49,200 --> 00:38:50,750 Let's continue. 597 00:38:50,750 --> 00:38:57,390 So the really [INAUDIBLE] like you haven't seen before. 598 00:38:57,390 --> 00:39:02,510 There is, as I said, unlike discretization in time, 599 00:39:02,510 --> 00:39:05,530 you only have one stamp of information, right? 600 00:39:05,530 --> 00:39:08,640 You can only view things one step at a time. 601 00:39:08,640 --> 00:39:11,660 You don't really know what happens tomorrow, what 602 00:39:11,660 --> 00:39:13,225 happens at the next timestamp. 603 00:39:13,225 --> 00:39:16,640 So you have to go one step at a time. 604 00:39:16,640 --> 00:39:19,140 We find a difference when we discretize things 605 00:39:19,140 --> 00:39:23,270 in space we actually have much more data 606 00:39:23,270 --> 00:39:26,910 than we have in ODE discreditization because we 607 00:39:26,910 --> 00:39:28,630 have the entire timestamp. 608 00:39:28,630 --> 00:39:33,520 At every grid point we have the solution in our head. 609 00:39:33,520 --> 00:39:34,770 OK. 610 00:39:34,770 --> 00:39:38,740 That makes it possible to write and find 611 00:39:38,740 --> 00:39:42,330 a difference in a matrix form. 612 00:39:42,330 --> 00:39:43,030 OK. 613 00:39:43,030 --> 00:39:46,630 So when we write the finite difference in the matrix form, 614 00:39:46,630 --> 00:39:51,380 we first need to write our solution in a vector form. 615 00:39:51,380 --> 00:39:54,810 We know our solution-- let's say we know our solution 616 00:39:54,810 --> 00:39:58,320 yields at the first grid point, u at the second grid 617 00:39:58,320 --> 00:40:00,330 point, u at the n-th grid point. 618 00:40:00,330 --> 00:40:04,020 We have them all, right? 619 00:40:04,020 --> 00:40:07,410 So that is what we have. 620 00:40:07,410 --> 00:40:14,570 Can we compute not d but partial-- partial u partial x 621 00:40:14,570 --> 00:40:18,150 at the first grid point, partial u partial x at the second grid 622 00:40:18,150 --> 00:40:18,740 point? 623 00:40:18,740 --> 00:40:21,810 Is that true of partial u, partial x at the last grid 624 00:40:21,810 --> 00:40:22,310 point? 625 00:40:27,080 --> 00:40:32,510 As a joint matrix-- I said joint matrix because sometimes 626 00:40:32,510 --> 00:40:36,720 when you have, let's say, a million grid points, how big 627 00:40:36,720 --> 00:40:38,080 is the matrix going to be? 628 00:40:41,700 --> 00:40:44,848 It's going to be a million by million matrix, right? 629 00:40:48,335 --> 00:40:50,210 It's going to be a million by million matrix. 630 00:40:50,210 --> 00:40:52,340 Think of n as a million. 631 00:40:52,340 --> 00:40:54,840 And this is why-- I don't know if some of you 632 00:40:54,840 --> 00:40:58,910 have heard of the term spark matrix. 633 00:40:58,910 --> 00:41:03,430 That is why spark matrices are invented because usually people 634 00:41:03,430 --> 00:41:05,530 don't have enough memory to store 635 00:41:05,530 --> 00:41:08,442 those million by million rate. 636 00:41:08,442 --> 00:41:09,900 I'm going to talk about that later. 637 00:41:09,900 --> 00:41:12,822 But sometimes you have this joint matrix. 638 00:41:12,822 --> 00:41:15,790 Now, what is this joint matrix? 639 00:41:15,790 --> 00:41:18,970 What are the elements in this joint matrix? 640 00:41:18,970 --> 00:41:20,800 If it is a central difference-- let 641 00:41:20,800 --> 00:41:23,990 me write down the central difference formula here. 642 00:41:23,990 --> 00:41:31,302 Let me write it here so that it's down here now. 643 00:41:31,302 --> 00:41:36,670 In a central difference, partial u, partial x at i 644 00:41:36,670 --> 00:41:41,600 is equal to u or i plus 1 minus Ui 645 00:41:41,600 --> 00:41:43,650 minus 1 divided by 2 delta x. 646 00:41:47,440 --> 00:41:50,570 And let's assume again we have here [INAUDIBLE] boundary 647 00:41:50,570 --> 00:41:55,830 condition so that if i is equal to n, 648 00:41:55,830 --> 00:42:01,480 then i plus 1 would be equal to 1. 649 00:42:04,320 --> 00:42:09,030 If i is equal to n, if i is the last grid point, then 650 00:42:09,030 --> 00:42:11,915 your neighbor who was y-- which actually, 651 00:42:11,915 --> 00:42:16,360 the first y of the other end. 652 00:42:16,360 --> 00:42:21,280 So n plus y is equal to y. 653 00:42:21,280 --> 00:42:23,978 What is the first line of the matrix? 654 00:42:23,978 --> 00:42:27,535 [INAUDIBLE] boundary condition. 655 00:42:27,535 --> 00:42:30,090 What happens if I want to approximate of e 656 00:42:30,090 --> 00:42:33,717 to the x at what, when i equals to what? 657 00:42:33,717 --> 00:42:34,550 STUDENT: [INAUDIBLE] 658 00:42:40,274 --> 00:42:40,940 QIQI WANG: Yeah. 659 00:42:40,940 --> 00:42:44,060 I have 0 here because this formula do not 660 00:42:44,060 --> 00:42:46,700 depend on u and i, right? 661 00:42:46,700 --> 00:42:50,415 Now when I go to the second one, what is the modify on u2? 662 00:42:50,415 --> 00:42:56,590 The modify on u2 is 1 over 2 down x, right? 663 00:42:56,590 --> 00:42:58,906 And is there any other than 0s? 664 00:42:58,906 --> 00:43:00,175 STUDENT: [INAUDIBLE]. 665 00:43:00,175 --> 00:43:02,470 QIQI WANG: All the way up to the end 666 00:43:02,470 --> 00:43:05,310 because I have periodic boundary condition, I have this. 667 00:43:08,850 --> 00:43:09,360 OK. 668 00:43:09,360 --> 00:43:10,443 How about the second line? 669 00:43:10,443 --> 00:43:13,900 The second one is actually a easier way to do it. 670 00:43:13,900 --> 00:43:15,516 When i is equal to 2? 671 00:43:21,580 --> 00:43:25,260 When i is equal 2, du dx at 2 is equal to y. 672 00:43:30,910 --> 00:43:35,290 It's equal to u3 minus u1 divided by 2 down x. 673 00:43:35,290 --> 00:43:39,660 So u3 and u1, which is based on this-- so this guy 674 00:43:39,660 --> 00:43:40,540 is now empty. 675 00:43:40,540 --> 00:43:43,980 This guy is now empty, right? 676 00:43:43,980 --> 00:43:46,810 We would get minus 1 over 2 down x here 677 00:43:46,810 --> 00:43:54,090 because u1 is being minused and u3 is being plussed. 678 00:43:54,090 --> 00:43:57,210 So we have 1 over 2 down x over here. 679 00:43:57,210 --> 00:44:00,730 We have 0 in the middle, 0, and 0. 680 00:44:00,730 --> 00:44:02,020 Everything else is 0. 681 00:44:02,020 --> 00:44:05,050 So I think under [INAUDIBLE] each line 682 00:44:05,050 --> 00:44:08,915 there is only going to be two non-zeros, only two non-zeros 683 00:44:08,915 --> 00:44:12,690 because each derivative only depends on two neighbors. 684 00:44:12,690 --> 00:44:18,561 That means we should only have two non-zeros. 685 00:44:18,561 --> 00:44:21,170 If you have more sets over here, then they 686 00:44:21,170 --> 00:44:24,318 are going to be more non-zeros. 687 00:44:24,318 --> 00:44:26,610 Two terms means two non-zeros for each line. 688 00:44:26,610 --> 00:44:32,840 And for the third one, my minus is going to be operating on u2. 689 00:44:32,840 --> 00:44:35,450 My plus is going to be operating on u4. 690 00:44:35,450 --> 00:44:38,880 And for the fourth line, my minus 691 00:44:38,880 --> 00:44:41,340 is going to be operated on u3. 692 00:44:41,340 --> 00:44:44,520 My plus is going to be operated on u5, 693 00:44:44,520 --> 00:44:46,730 and et cetera, et cetera. 694 00:44:46,730 --> 00:44:50,410 So diagonally, it's always 0 towards the very last line. 695 00:44:50,410 --> 00:44:55,860 The sub-diagonal is always going to be minus 2, minus 1 696 00:44:55,860 --> 00:44:58,980 over 2 delta x until the last line. 697 00:44:58,980 --> 00:45:05,400 And the upper diagonal is always going to be 1 over 2 delta x. 698 00:45:05,400 --> 00:45:07,584 Am I missing something here? 699 00:45:07,584 --> 00:45:10,480 STUDENT: [INAUDIBLE]. 700 00:45:10,480 --> 00:45:12,450 QIQI WANG: So the last one, the positive, 701 00:45:12,450 --> 00:45:16,071 is over here because of the periodic boundary condition. 702 00:45:16,071 --> 00:45:16,570 Yes? 703 00:45:16,570 --> 00:45:17,445 STUDENT: [INAUDIBLE]. 704 00:45:20,829 --> 00:45:21,620 QIQI WANG: Exactly. 705 00:45:21,620 --> 00:45:25,020 Because we also need a periodic boundary condition, 706 00:45:25,020 --> 00:45:27,890 this point, instead of lying over here, 707 00:45:27,890 --> 00:45:32,309 there is no longer anything [INAUDIBLE] anymore. 708 00:45:32,309 --> 00:45:35,350 It is actually the first element of the left. 709 00:45:35,350 --> 00:45:38,771 This entry, no matter how matrix multiply with a vector? 710 00:45:38,771 --> 00:45:41,115 This entry is going to be multiplied 711 00:45:41,115 --> 00:45:48,982 [INAUDIBLE] instead of U n plus 1, which [INAUDIBLE]. 712 00:45:54,110 --> 00:45:58,350 Any question on this [INAUDIBLE] matrix? 713 00:45:58,350 --> 00:46:01,444 So all of this matrix is really a million by million. 714 00:46:01,444 --> 00:46:04,870 But it only compares two a million, 1, 0 entries. 715 00:46:04,870 --> 00:46:06,680 Most computers have enough memory 716 00:46:06,680 --> 00:46:10,650 to store a million non-zero entries. 717 00:46:10,650 --> 00:46:11,280 All right. 718 00:46:11,280 --> 00:46:12,530 So this is central difference. 719 00:46:12,530 --> 00:46:16,576 Let's just do an exercise of how, if we do a-- oh, 720 00:46:16,576 --> 00:46:25,170 I haven't talked about upwind yet, so backward 721 00:46:25,170 --> 00:46:29,861 in space difference. 722 00:46:29,861 --> 00:46:31,691 STUDENT: [INAUDIBLE]. 723 00:46:31,691 --> 00:46:32,316 QIQI WANG: Huh? 724 00:46:32,316 --> 00:46:33,149 STUDENT: [INAUDIBLE] 725 00:46:37,226 --> 00:46:39,460 QIQI WANG: Towards the upwind of the [INAUDIBLE]. 726 00:46:39,460 --> 00:46:41,430 Good guess. 727 00:46:41,430 --> 00:46:41,930 Right. 728 00:46:41,930 --> 00:46:45,890 So if I do a backward in space, I'm 729 00:46:45,890 --> 00:46:49,530 going to be writing the same thing, partial u partial x 730 00:46:49,530 --> 00:46:53,360 at 1, partial u, partial x at 2 essential, partial u 731 00:46:53,360 --> 00:46:54,570 partial x at n. 732 00:46:59,462 --> 00:47:01,985 I think I used a small-- yeah. 733 00:47:01,985 --> 00:47:12,480 I used a small n-- is equal to a joint matrix of the same size 734 00:47:12,480 --> 00:47:14,970 times u1, u2, et cetera. 735 00:47:14,970 --> 00:47:20,870 So nothing has changed, except for the content of the matrix. 736 00:47:20,870 --> 00:47:28,010 And a backwards space difference is partial u partial x at i 737 00:47:28,010 --> 00:47:32,170 is equal to Ui minus Ui minus 1 divided by delta x. 738 00:47:35,190 --> 00:47:35,690 All right. 739 00:47:35,690 --> 00:47:37,720 Somebody help me fill in the blanks. 740 00:47:40,480 --> 00:47:43,400 Fill the blanks of a million by million matrix. 741 00:47:47,780 --> 00:47:53,730 Doesn't take that much time to fill in, actually. 742 00:47:53,730 --> 00:47:56,072 What is the first top level entry? 743 00:47:56,072 --> 00:47:57,490 STUDENT: One over delta x. 744 00:47:57,490 --> 00:47:58,656 QIQI WANG: One over delta x. 745 00:47:58,656 --> 00:48:05,880 It is no longer 0 because the du dx at ix usually depends on Ui. 746 00:48:05,880 --> 00:48:10,250 In the last case, the du dx at i does not depend on Ui. 747 00:48:10,250 --> 00:48:13,510 So we have one other entry because we have two elements 748 00:48:13,510 --> 00:48:14,850 in each derivative. 749 00:48:14,850 --> 00:48:17,520 What is the other non-zero entry? 750 00:48:17,520 --> 00:48:18,956 STUDENT: At the very end. 751 00:48:18,956 --> 00:48:20,080 QIQI WANG: At the very end. 752 00:48:20,080 --> 00:48:22,322 That one is the same. 753 00:48:22,322 --> 00:48:24,970 All the others are 0's. 754 00:48:24,970 --> 00:48:28,710 How about the second line? 755 00:48:28,710 --> 00:48:32,710 We have diagonals to be always 1 over delta 756 00:48:32,710 --> 00:48:38,590 x because we always have 1 over delta x multiplied by Ui. 757 00:48:38,590 --> 00:48:41,600 That going to be du dxi. 758 00:48:41,600 --> 00:48:44,870 And we have 1 minues-- sorry. 759 00:48:44,870 --> 00:48:49,580 We have minus of 1 over delta x always towards the left 760 00:48:49,580 --> 00:48:55,149 because the value at the left is always multiplied by minus 1 761 00:48:55,149 --> 00:48:56,334 over delta x. 762 00:48:59,178 --> 00:49:01,870 All right? 763 00:49:01,870 --> 00:49:02,370 OK. 764 00:49:02,370 --> 00:49:03,881 Another x. 765 00:49:03,881 --> 00:49:04,380 So OK. 766 00:49:04,380 --> 00:49:07,720 So how about let's try to, in MATLAB, 767 00:49:07,720 --> 00:49:16,380 try to construct the matrix form. 768 00:49:16,380 --> 00:49:17,830 When we construct the matrix form, 769 00:49:17,830 --> 00:49:20,210 we don't need to do it in every concept. 770 00:49:20,210 --> 00:49:24,660 We an do it well in advance. 771 00:49:24,660 --> 00:49:26,520 So after we settle initial conditions, 772 00:49:26,520 --> 00:49:28,990 let's actually-- before we settle our initial conditions, 773 00:49:28,990 --> 00:49:33,436 we know what n is, we try to set up matrix a. 774 00:49:36,130 --> 00:49:37,700 OK. 775 00:49:37,700 --> 00:49:39,290 Let's call it a ddt. 776 00:49:39,290 --> 00:49:45,410 So that is the matrix that gives me-- sorry-- ddx, that gives me 777 00:49:45,410 --> 00:49:48,620 derivative to x. 778 00:49:48,620 --> 00:49:50,060 So let me see what I did. 779 00:49:50,060 --> 00:49:51,540 Here is actually backward in space. 780 00:49:51,540 --> 00:49:53,850 So let's try to reproduce backward in space. 781 00:49:58,290 --> 00:50:00,457 This is the matrix I have. 782 00:50:00,457 --> 00:50:01,790 I already have delta x computed. 783 00:50:01,790 --> 00:50:03,520 Yes, I do. 784 00:50:03,520 --> 00:50:07,310 So then I need two matrices. 785 00:50:07,310 --> 00:50:10,500 One matrix, the first matrix, is this guy. 786 00:50:13,200 --> 00:50:15,890 I need, first of all, this matrix. 787 00:50:15,890 --> 00:50:21,970 And somehow if I can add that matrix to the second matrix, 788 00:50:21,970 --> 00:50:26,090 if I can add that matrix to this matrix plus this little element 789 00:50:26,090 --> 00:50:31,200 over here, then I have the entire matrix. 790 00:50:31,200 --> 00:50:36,322 So let's look at the diagonals, the blue one. 791 00:50:36,322 --> 00:50:40,196 Can everybody tell me, is there an easy way 792 00:50:40,196 --> 00:50:41,588 to [INAUDIBLE] the blue matrix? 793 00:50:41,588 --> 00:50:42,980 STUDENT: [INAUDIBLE]. 794 00:50:42,980 --> 00:50:44,760 QIQI WANG: Huh? 795 00:50:44,760 --> 00:50:52,140 It's identity, it's identity matrix times one over delta x. 796 00:50:52,140 --> 00:50:54,025 That one is actually super easy. 797 00:51:01,945 --> 00:51:03,570 How about the other one? 798 00:51:03,570 --> 00:51:06,055 How about the black one? 799 00:51:06,055 --> 00:51:06,930 STUDENT: [INAUDIBLE]. 800 00:51:09,215 --> 00:51:09,840 QIQI WANG: Yes. 801 00:51:09,840 --> 00:51:11,310 I can use my x. 802 00:51:11,310 --> 00:51:14,150 I can use diag if I don't have this one. 803 00:51:14,150 --> 00:51:17,070 I'm going to see later on if I have not 804 00:51:17,070 --> 00:51:18,472 periodic boundary condition. 805 00:51:18,472 --> 00:51:20,400 Periodic boundary condition is actually this. 806 00:51:20,400 --> 00:51:22,810 If I don't have periodic boundary condition, 807 00:51:22,810 --> 00:51:28,190 [INAUDIBLE] then diag is a very good way to do it. 808 00:51:28,190 --> 00:51:30,330 In this case, I'm going to use the same function, 809 00:51:30,330 --> 00:51:35,770 the third shift I just used to centrally shift the solution 810 00:51:35,770 --> 00:51:36,420 itself. 811 00:51:36,420 --> 00:51:39,508 I can also shift the matrix. 812 00:51:39,508 --> 00:51:44,340 I can take this matrix, shift it to the left 813 00:51:44,340 --> 00:51:46,562 or towards the bottom. 814 00:51:46,562 --> 00:51:48,260 It's the same way. 815 00:51:48,260 --> 00:51:52,410 I'm going to get the back matrix. 816 00:51:52,410 --> 00:51:57,800 It is equal to i of n divided by delta x. 817 00:51:57,800 --> 00:52:01,020 So that gives me the blue one. 818 00:52:01,020 --> 00:52:05,340 I'm going to minus in by dx. 819 00:52:05,340 --> 00:52:12,450 But I'm going to circshift the whole matrix by left 2 820 00:52:12,450 --> 00:52:13,490 towards the bottom. 821 00:52:13,490 --> 00:52:15,880 Towards the bottom is [INAUDIBLE] 822 00:52:15,880 --> 00:52:20,110 in the third direction, 1 in the other direction, 823 00:52:20,110 --> 00:52:21,820 0 in the [INAUDIBLE] direction. 824 00:52:21,820 --> 00:52:26,380 So I'm going to shift it by 1 and 0. 825 00:52:26,380 --> 00:52:27,770 OK. 826 00:52:27,770 --> 00:52:31,477 That is my plan a difference matrix. 827 00:52:34,400 --> 00:52:36,740 Now how do I apply it? 828 00:52:36,740 --> 00:52:39,190 How to apply it-- when I computed 829 00:52:39,190 --> 00:52:47,050 du dx, When I compute du dx-- let me first do one thing. 830 00:52:49,840 --> 00:52:53,790 I want to make my everything to be a color matrix first because 831 00:52:53,790 --> 00:52:57,250 by default, if I do 1 to n, it's a row matrix. 832 00:52:57,250 --> 00:53:00,890 Where if I want to multiply the matrices that way, 833 00:53:00,890 --> 00:53:05,000 I need my solutions to be like a column. 834 00:53:05,000 --> 00:53:08,950 So initially, I want to construct this by columns. 835 00:53:08,950 --> 00:53:11,340 And everything should be in columns. 836 00:53:11,340 --> 00:53:14,300 And this is no longer true anymore. 837 00:53:14,300 --> 00:53:17,335 I'm going to remove this. 838 00:53:17,335 --> 00:53:20,600 I'm going to just do a linear advection equation first. 839 00:53:20,600 --> 00:53:27,380 But my du dx is equal to a_ddx times u. 840 00:53:27,380 --> 00:53:32,800 That's how easy it is to apply this on a difference matrix. 841 00:53:32,800 --> 00:53:35,690 Also, I have the final difference matrix, 842 00:53:35,690 --> 00:53:39,720 I don't need to do anything at each concept other 843 00:53:39,720 --> 00:53:43,815 than just applying the matrix just as if it 844 00:53:43,815 --> 00:53:47,260 is the mathematical operator. 845 00:53:47,260 --> 00:53:50,080 I just think this matrix is my actual [INAUDIBLE]. 846 00:53:50,080 --> 00:53:55,830 I apply on top of u, I get partial u partial x. 847 00:53:55,830 --> 00:53:59,214 So this a serves like a mathematical operator. 848 00:53:59,214 --> 00:54:00,580 I'm going to round this. 849 00:54:03,430 --> 00:54:06,450 I'm going to get the same solution. 850 00:54:06,450 --> 00:54:08,000 Of course, this is backward in space. 851 00:54:08,000 --> 00:54:11,660 I got a solution that moves towards the right but also 852 00:54:11,660 --> 00:54:13,370 the case. 853 00:54:13,370 --> 00:54:19,150 So this is what I have as a backwards difference. 854 00:54:19,150 --> 00:54:24,240 And I can modify this. 855 00:54:24,240 --> 00:54:26,200 So I'm going to [INAUDIBLE] this out. 856 00:54:26,200 --> 00:54:29,290 This is backward difference. 857 00:54:29,290 --> 00:54:31,680 I'm going to do central. 858 00:54:31,680 --> 00:54:34,230 And in the central, the difference 859 00:54:34,230 --> 00:54:37,635 is I need to circshift both. 860 00:54:37,635 --> 00:54:42,215 I need to circshift this in the opposite direction. 861 00:54:42,215 --> 00:54:48,490 And instead of dividing by 1 delta x, actually, let 862 00:54:48,490 --> 00:54:53,642 me divide this by 2 delta x. 863 00:54:53,642 --> 00:54:56,978 So this is going to be my central difference, right? 864 00:54:59,660 --> 00:55:00,160 Agreed? 865 00:55:02,890 --> 00:55:10,636 If you look at this, I have one identity matrix. 866 00:55:10,636 --> 00:55:11,940 shifted towards the right. 867 00:55:11,940 --> 00:55:15,900 And I have another one shifted towards the left. 868 00:55:15,900 --> 00:55:18,820 So I get two matrices subtracted. 869 00:55:18,820 --> 00:55:21,762 I get the central difference. 870 00:55:21,762 --> 00:55:24,820 Let me look at delta behavior. 871 00:55:24,820 --> 00:55:27,222 Looks like the same as the central difference. 872 00:55:27,222 --> 00:55:28,575 It does, right? 873 00:55:28,575 --> 00:55:31,310 I have a solution where we go to right. 874 00:55:31,310 --> 00:55:33,270 It doesn't really decay at all. 875 00:55:33,270 --> 00:55:35,230 But [INAUDIBLE] a little bit. 876 00:55:42,090 --> 00:55:44,306 [INAUDIBLE] if the maximum occasionally 877 00:55:44,306 --> 00:55:51,726 gets greater than 1, it still shifts down a little bit. 878 00:55:51,726 --> 00:55:53,610 All right. 879 00:55:53,610 --> 00:55:59,302 Any questions on the matrix form of these two final difference 880 00:55:59,302 --> 00:55:59,802 operators? 881 00:56:04,320 --> 00:56:04,820 No? 882 00:56:04,820 --> 00:56:07,090 Whenever you need them, I'm basically 883 00:56:07,090 --> 00:56:10,570 constructing a final difference operator just 884 00:56:10,570 --> 00:56:13,660 like a mathematical operator, just like ddx. 885 00:56:16,480 --> 00:56:19,630 And when I need it, I can just apply it. 886 00:56:24,800 --> 00:56:27,620 The interesting thing is that the operator I 887 00:56:27,620 --> 00:56:32,253 have already contains the boundary condition. 888 00:56:35,960 --> 00:56:40,330 The operator I have here, the periodic boundary condition 889 00:56:40,330 --> 00:56:44,290 is encoding into the operator [INAUDIBLE]. 890 00:56:47,120 --> 00:56:49,770 If I didn't have periodic boundary condition, 891 00:56:49,770 --> 00:56:51,830 would I still have this? 892 00:56:51,830 --> 00:56:53,510 No. 893 00:56:53,510 --> 00:56:55,560 I wouldn't be able to say, if I want 894 00:56:55,560 --> 00:56:58,222 to-- I wouldn't be able to say if I only 895 00:56:58,222 --> 00:57:01,660 graph the solution towards the left, 896 00:57:01,660 --> 00:57:05,376 I just need to grab the one at the right hand. 897 00:57:05,376 --> 00:57:07,994 I wouldn't be able to say that. 898 00:57:07,994 --> 00:57:10,960 So what if we-- let's say we have a boundary 899 00:57:10,960 --> 00:57:13,450 condition at the left, but if it is not 900 00:57:13,450 --> 00:57:16,726 periodic, what if we have a boundary condition that 901 00:57:16,726 --> 00:57:19,360 says u at 0 equal to 1? 902 00:57:19,360 --> 00:57:19,860 OK. 903 00:57:19,860 --> 00:57:22,440 So let's see. 904 00:57:22,440 --> 00:57:30,640 U at x equal to 0 at net equal to 1. 905 00:57:30,640 --> 00:57:34,490 This is consistent with our matching question, 906 00:57:34,490 --> 00:57:36,310 because in this matching equation, 907 00:57:36,310 --> 00:57:39,500 the characteristics move towards the right. 908 00:57:39,500 --> 00:57:42,430 So if you didn't have periodic boundary condition, 909 00:57:42,430 --> 00:57:45,280 you need to specify the solution. 910 00:57:45,280 --> 00:57:50,090 You need to specify the solution also here and here, right? 911 00:57:50,090 --> 00:57:52,700 You need to specify the solution where 912 00:57:52,700 --> 00:57:56,290 the characteristics originate. 913 00:57:56,290 --> 00:57:59,522 Because if I'm here, I have the initial condition 914 00:57:59,522 --> 00:58:01,150 that p is equal to 0. 915 00:58:01,150 --> 00:58:04,690 You also need to specify those conditions here, 916 00:58:04,690 --> 00:58:06,108 either boundary conditions. 917 00:58:06,108 --> 00:58:10,179 That is when x is equal to 0 or x 918 00:58:10,179 --> 00:58:14,351 is at the left end of the domain, [INAUDIBLE] equal to 0. 919 00:58:17,190 --> 00:58:21,174 So this is the left boundary condition. 920 00:58:24,273 --> 00:58:25,260 All right? 921 00:58:25,260 --> 00:58:27,230 OK. 922 00:58:27,230 --> 00:58:30,880 In that case, how do we deal with that? 923 00:58:30,880 --> 00:58:34,540 How do we encode that boundary condition into the matrix, 924 00:58:34,540 --> 00:58:39,910 into the matrix form of finite difference. 925 00:58:39,910 --> 00:58:43,540 Let's look at this. 926 00:58:43,540 --> 00:58:46,120 Let's take a look at the matrix. 927 00:58:46,120 --> 00:58:52,000 And the only thing we need to change is which one? 928 00:58:52,000 --> 00:58:55,050 Which row of the matrix do we need to change? 929 00:58:55,050 --> 00:58:57,930 If we need to change one at all. 930 00:58:57,930 --> 00:59:00,040 We only need to change the first row, right? 931 00:59:00,040 --> 00:59:02,666 Because all the other rows of the matrix 932 00:59:02,666 --> 00:59:06,150 are still exactly the same because they are the interior. 933 00:59:06,150 --> 00:59:08,860 Only the first row involves the boundary. 934 00:59:08,860 --> 00:59:12,170 So let's look at the first row. 935 00:59:12,170 --> 00:59:16,620 The first row has partial u, partial x at r 936 00:59:16,620 --> 00:59:20,430 equal to 1 at n [INAUDIBLE]. 937 00:59:20,430 --> 00:59:24,180 Originally, it is equal to u of i minus 1, 938 00:59:24,180 --> 00:59:29,620 which is in this case is 0 minus u1 divided by delta x. 939 00:59:29,620 --> 00:59:41,220 This is my backward-- again, this is my backward in space. 940 00:59:41,220 --> 00:59:45,702 This-- yeah. 941 00:59:45,702 --> 00:59:47,490 It's the other way around. 942 00:59:47,490 --> 00:59:48,310 Thank you. 943 00:59:48,310 --> 00:59:50,580 It is u1 minus u0. 944 00:59:50,580 --> 00:59:51,080 Yes. 945 00:59:56,800 --> 00:59:57,330 OK. 946 00:59:57,330 --> 01:00:00,880 In the previous [INAUDIBLE] we said the domain is periodic. 947 01:00:00,880 --> 01:00:03,512 So 0 is just U n, right? 948 01:00:03,512 --> 01:00:07,570 So what this is is that we have a boundary 949 01:00:07,570 --> 01:00:10,600 condition that is given to us. 950 01:00:10,600 --> 01:00:14,270 You know what exactly U0 is. 951 01:00:14,270 --> 01:00:20,280 We know that your 0 is equal to 1. 952 01:00:20,280 --> 01:00:26,500 Then the derivative is u1 over delta x minus 1 over delta x. 953 01:00:29,840 --> 01:00:33,880 We have a term that doesn't depend linearly 954 01:00:33,880 --> 01:00:34,651 on the solution. 955 01:00:37,420 --> 01:00:42,140 Or, if you look at the matrix form, 956 01:00:42,140 --> 01:00:46,130 we have multiple conditions all the way. 957 01:00:46,130 --> 01:00:47,520 We don't have this. 958 01:00:47,520 --> 01:00:49,770 But in addition to the matrix, we have something else. 959 01:00:52,750 --> 01:00:55,490 Obviously, we have a negative of 1 960 01:00:55,490 --> 01:01:00,830 over delta x sitting over here as an additional vector 961 01:01:00,830 --> 01:01:04,870 to this matrix. 962 01:01:04,870 --> 01:01:06,770 Let me make a new page. 963 01:01:11,630 --> 01:01:12,130 OK. 964 01:01:12,130 --> 01:01:16,020 I'm going to draw what the matrix is going to look like. 965 01:01:16,020 --> 01:01:20,510 When we have a boundary condition, like partial u, 966 01:01:20,510 --> 01:01:25,770 partial x at 1, partial u, partial x at 2, partial u, 967 01:01:25,770 --> 01:01:39,840 partial x at n is equal to a similar matrix at minus delta 968 01:01:39,840 --> 01:01:41,195 x on the sun diagonal. 969 01:01:44,888 --> 01:01:49,650 I want to leave enough space for the vector ends on the right. 970 01:01:49,650 --> 01:01:56,760 My u1-- I'll think I'll use the big U for the first U n. 971 01:01:56,760 --> 01:02:04,510 This is the big U plus something else. 972 01:02:04,510 --> 01:02:06,990 And that something else is going to be 973 01:02:06,990 --> 01:02:13,090 0 almost everywhere except for the first row, which is minus 1 974 01:02:13,090 --> 01:02:14,790 over delta x. 975 01:02:14,790 --> 01:02:18,090 And it is going to be the 0 everywhere because I 976 01:02:18,090 --> 01:02:20,340 don't need to modify anything. 977 01:02:24,480 --> 01:02:26,700 How id I achieve this? 978 01:02:26,700 --> 01:02:31,490 I plucked the boundary condition into the finite difference 979 01:02:31,490 --> 01:02:37,651 formula at the grid point that is close to the boundary. 980 01:02:37,651 --> 01:02:38,490 All right? 981 01:02:38,490 --> 01:02:41,050 That is a general technique of locking 982 01:02:41,050 --> 01:02:43,540 in the value of the boundary condition 983 01:02:43,540 --> 01:02:46,560 into the [INAUDIBLE] difference here. 984 01:02:51,140 --> 01:02:55,870 So let's modify what we did under here. 985 01:02:55,870 --> 01:03:02,400 So let's copy this. 986 01:03:02,400 --> 01:03:06,720 I think I should rename this as backward 987 01:03:06,720 --> 01:03:10,440 because this is backwards. 988 01:03:10,440 --> 01:03:15,210 And I'm going to do probably another one 989 01:03:15,210 --> 01:03:21,670 and say boundary condition backwards space forward time. 990 01:03:21,670 --> 01:03:23,310 That's correct. 991 01:03:23,310 --> 01:03:24,780 So what do I need to do? 992 01:03:24,780 --> 01:03:28,640 I need to change-- oh, OK. 993 01:03:28,640 --> 01:03:31,380 I need to change the operator. 994 01:03:31,380 --> 01:03:38,030 I need to change the operator to include the boundary condition. 995 01:03:38,030 --> 01:03:40,460 How do I do that? 996 01:03:40,460 --> 01:03:42,810 If you look at what the matrix is like, 997 01:03:42,810 --> 01:03:46,310 I still have the diagonal term to be exactly the same. 998 01:03:46,310 --> 01:03:50,590 I still have my identity of n divided by delta x. 999 01:03:50,590 --> 01:03:56,560 So that is this part. 1000 01:03:56,560 --> 01:04:01,260 Now, I also have my rare part, which is not exactly 1001 01:04:01,260 --> 01:04:06,360 a circular shift of identity matrix. 1002 01:04:06,360 --> 01:04:09,780 So here I'm going to use the function code diag. 1003 01:04:12,390 --> 01:04:18,710 Diag, it's a function that you need to give to me. 1004 01:04:18,710 --> 01:04:21,430 What are the elements of a diagonal 1005 01:04:21,430 --> 01:04:25,140 and how much I shifted. 1006 01:04:25,140 --> 01:04:27,675 If a is equal to 0, then elements 1007 01:04:27,675 --> 01:04:29,626 aren't exactly on the diagonal. 1008 01:04:29,626 --> 01:04:33,278 If a is equal to minus 1 then I get exactly what 1009 01:04:33,278 --> 01:04:38,880 I want because it's minus 1 shifted 1010 01:04:38,880 --> 01:04:41,410 towards the opposite diagonal, which is 1 shifted 1011 01:04:41,410 --> 01:04:42,780 towards the lower diagonal. 1012 01:04:42,780 --> 01:04:50,530 So the elements would be once with m minus 1 elements 1013 01:04:50,530 --> 01:04:55,520 divided by delta x-- these are the values-- and minus 1 1014 01:04:55,520 --> 01:04:57,830 towards the shift. 1015 01:04:57,830 --> 01:04:58,670 OK. 1016 01:04:58,670 --> 01:05:04,020 So this is what the matrix is going to be like. 1017 01:05:04,020 --> 01:05:09,420 I'm going to paste it here and take a look at the matrix. 1018 01:05:09,420 --> 01:05:13,200 The 100 by 100 double on the diagonal [INAUDIBLE]. 1019 01:05:16,630 --> 01:05:19,360 I get what I want, and I also don't 1020 01:05:19,360 --> 01:05:29,080 have this-- I don't have a minus 100 over here 1021 01:05:29,080 --> 01:05:30,773 in the periodic case. 1022 01:05:34,090 --> 01:05:38,050 Now, let's run it to see what we have. 1023 01:05:38,050 --> 01:05:38,570 OK. 1024 01:05:38,570 --> 01:05:49,660 We still see these things going over here. 1025 01:05:49,660 --> 01:05:52,500 What happens on my left? 1026 01:05:52,500 --> 01:05:54,920 Oh, OK. 1027 01:05:54,920 --> 01:05:58,320 Did I forget something? 1028 01:05:58,320 --> 01:05:59,980 I forgot the boundary condition. 1029 01:05:59,980 --> 01:06:05,740 So I forgot to add the vector v when I applied this derivative. 1030 01:06:05,740 --> 01:06:10,660 The end result here is I have a boundary condition of 0 here. 1031 01:06:10,660 --> 01:06:15,115 I'm setting the boundary condition to be 0. 1032 01:06:15,115 --> 01:06:16,570 [INAUDIBLE] 1033 01:06:16,570 --> 01:06:18,530 As this thing advances towards the right, 1034 01:06:18,530 --> 01:06:21,850 it's going to be no longer [INAUDIBLE] towards the left. 1035 01:06:21,850 --> 01:06:23,815 So yeah. 1036 01:06:23,815 --> 01:06:25,720 So I did forget something. 1037 01:06:25,720 --> 01:06:28,520 But we still have such a boundary condition 1038 01:06:28,520 --> 01:06:31,660 that is not periodic. 1039 01:06:31,660 --> 01:06:33,702 Because you see this [INAUDIBLE] go out, 1040 01:06:33,702 --> 01:06:36,760 I'm still going to have 0 here. 1041 01:06:36,760 --> 01:06:37,260 OK. 1042 01:06:37,260 --> 01:06:40,958 So let's add to the b. 1043 01:06:40,958 --> 01:06:45,040 My b_ddx is going to be 0n1. 1044 01:06:47,850 --> 01:06:54,305 And my b_ddx, the first element is going to be 1 minus delta x. 1045 01:06:54,305 --> 01:06:55,760 Minus. 1046 01:06:55,760 --> 01:06:56,260 All right. 1047 01:06:56,260 --> 01:07:00,730 When I apply it ddx is this plus [INAUDIBLE]. 1048 01:07:00,730 --> 01:07:01,230 Yeah. 1049 01:07:01,230 --> 01:07:02,870 This is still going towards the right, 1050 01:07:02,870 --> 01:07:04,960 and it doesn't come back from the left. 1051 01:07:04,960 --> 01:07:08,350 So now let's look at what if we do 1052 01:07:08,350 --> 01:07:12,285 have a non-trivial boundary condition. 1053 01:07:12,285 --> 01:07:13,752 Why? 1054 01:07:13,752 --> 01:07:14,730 What happens? 1055 01:07:20,110 --> 01:07:25,260 Ah, undefine the functional variable, b_ddx. 1056 01:07:25,260 --> 01:07:25,760 All right. 1057 01:07:25,760 --> 01:07:27,440 I'm going to round it. 1058 01:07:27,440 --> 01:07:30,035 All right. 1059 01:07:30,035 --> 01:07:34,982 So we have a boundary condition of b equal to 1 over here 1060 01:07:34,982 --> 01:07:36,401 as you can see. 1061 01:07:36,401 --> 01:07:39,900 This is the behavior of the differential equation 1062 01:07:39,900 --> 01:07:42,760 [INAUDIBLE] so we'll see everything 1063 01:07:42,760 --> 01:07:44,582 that wraps towards the right. 1064 01:07:44,582 --> 01:07:51,004 And [INAUDIBLE] there shouldn't be a discontinuity over here, 1065 01:07:51,004 --> 01:07:54,824 but the [INAUDIBLE] actually moves this discontinuity out, 1066 01:07:54,824 --> 01:08:01,782 and you get this finite jump from 0 to 1 over here. 1067 01:08:01,782 --> 01:08:04,590 But you still the boundary condition 1068 01:08:04,590 --> 01:08:09,190 being forced correctly as things do move towards the right. 1069 01:08:09,190 --> 01:08:11,290 All right? 1070 01:08:11,290 --> 01:08:15,720 So the right way to put boundary conditions, one right way 1071 01:08:15,720 --> 01:08:17,170 to put the boundary conditions is 1072 01:08:17,170 --> 01:08:22,080 to substitute the boundary value into the differential operator, 1073 01:08:22,080 --> 01:08:26,240 into the discrete highest differential operator 1074 01:08:26,240 --> 01:08:30,270 and derive not only a more refined matrix 1075 01:08:30,270 --> 01:08:34,324 form, but also a vector that added on to the matrix form. 1076 01:08:34,324 --> 01:08:35,199 STUDENT: [INAUDIBLE]. 1077 01:08:46,696 --> 01:08:47,279 QIQI WANG: OK. 1078 01:08:47,279 --> 01:08:51,010 So the question is, this form o the boundary condition looks 1079 01:08:51,010 --> 01:08:56,760 like we are asking a [INAUDIBLE] into the differential equation. 1080 01:08:56,760 --> 01:08:59,764 And you are absolutely correct. 1081 01:08:59,764 --> 01:09:01,930 I think not only in this case, but in several others 1082 01:09:01,930 --> 01:09:07,779 [INAUDIBLE] of laying the boundary condition, 1083 01:09:07,779 --> 01:09:09,979 it's essentially adding a [INAUDIBLE], 1084 01:09:09,979 --> 01:09:12,951 like [INAUDIBLE] boundary condition. 1085 01:09:12,951 --> 01:09:14,909 So sometimes [INAUDIBLE] the boundary condition 1086 01:09:14,909 --> 01:09:18,899 is like knowing how to add the fore onto the right-hand side 1087 01:09:18,899 --> 01:09:22,550 near the boundary to-- so that your emergence 1088 01:09:22,550 --> 01:09:25,220 solution converges to the analytical solution 1089 01:09:25,220 --> 01:09:28,862 with that boundary condition. 1090 01:09:28,862 --> 01:09:29,361 All right? 1091 01:09:29,361 --> 01:09:30,691 Did I answer your question? 1092 01:09:30,691 --> 01:09:31,191 Does that? 1093 01:09:31,191 --> 01:09:32,066 STUDENT: [INAUDIBLE]. 1094 01:09:43,479 --> 01:09:47,819 QIQI WANG: So the graph I have is-- the graph 1095 01:09:47,819 --> 01:09:51,233 I have is not with the boundary condition 1096 01:09:51,233 --> 01:09:53,950 but due to the minor difference here. 1097 01:09:53,950 --> 01:09:57,070 Yeah, the scheme is on the-- gives you a truncation error. 1098 01:09:57,070 --> 01:10:01,830 It is marked on the [INAUDIBLE] derivative exactly 1099 01:10:01,830 --> 01:10:06,270 on that truncation error. [INAUDIBLE] 1100 01:10:06,270 --> 01:10:09,530 smooths out any discontinuities, if there's computation error, 1101 01:10:09,530 --> 01:10:11,390 you can actually see that a truncation error 1102 01:10:11,390 --> 01:10:16,260 looks like a diffusion here. 1103 01:10:16,260 --> 01:10:19,190 It looks like you're diffusing your solution out instead 1104 01:10:19,190 --> 01:10:21,230 of just advecting it. 1105 01:10:21,230 --> 01:10:23,700 And the behavior of the central difference scheme 1106 01:10:23,700 --> 01:10:24,640 is very different. 1107 01:10:30,801 --> 01:10:31,300 All right. 1108 01:10:34,520 --> 01:10:36,260 OK. 1109 01:10:36,260 --> 01:10:42,940 I'm just going to very quickly also give you 1110 01:10:42,940 --> 01:10:45,590 the finite difference form, the matrix 1111 01:10:45,590 --> 01:10:48,460 form of the second order derivative. 1112 01:10:48,460 --> 01:10:50,640 The matrix form of the second order derivative 1113 01:10:50,640 --> 01:10:56,650 is if you have the second order derivative of u at 1 1114 01:10:56,650 --> 01:11:05,020 and the second order derivative of u at n-- 1115 01:11:05,020 --> 01:11:08,470 again, is equal to this joint matrix. 1116 01:11:08,470 --> 01:11:11,115 And again, let's assume is periodic boundary conditions 1117 01:11:11,115 --> 01:11:13,430 so that we don't have to worry about the boundary 1118 01:11:13,430 --> 01:11:14,343 conditions for now. 1119 01:11:23,771 --> 01:11:24,270 OK. 1120 01:11:24,270 --> 01:11:27,470 So the second derivative, partial u, partial square u, 1121 01:11:27,470 --> 01:11:33,100 partial x at i is equal to three terms. 1122 01:11:33,100 --> 01:11:37,920 We have a u of i plus 1 over delta 1123 01:11:37,920 --> 01:11:45,170 x squared minus 2Ui over delta x squared plus Ui plus 1 1124 01:11:45,170 --> 01:11:47,790 over delta x squared, right? 1125 01:11:47,790 --> 01:11:56,096 [INAUDIBLE] the same as the second order [INAUDIBLE]. 1126 01:11:59,090 --> 01:12:03,940 So Ui plus 1 minus 2Ui plus Ui plus 1, everything 1127 01:12:03,940 --> 01:12:07,929 divided by delta x squared. 1128 01:12:07,929 --> 01:12:09,720 Now if we have periodic boundary condition, 1129 01:12:09,720 --> 01:12:12,570 how do I fit this into the matrix? 1130 01:12:17,494 --> 01:12:18,369 STUDENT: [INAUDIBLE]. 1131 01:12:27,222 --> 01:12:28,158 QIQI WANG: Sorry? 1132 01:12:28,158 --> 01:12:29,033 STUDENT: [INAUDIBLE]. 1133 01:12:31,037 --> 01:12:32,120 QIQI WANG: The derivative. 1134 01:12:32,120 --> 01:12:32,590 Oh, the derivative. 1135 01:12:32,590 --> 01:12:33,090 Yes. 1136 01:12:33,090 --> 01:12:34,680 Thank you. 1137 01:12:34,680 --> 01:12:36,840 Yes. 1138 01:12:36,840 --> 01:12:38,740 Yes. 1139 01:12:38,740 --> 01:12:39,240 OK. 1140 01:12:44,080 --> 01:12:47,510 All of these terms going to that matrix. 1141 01:12:47,510 --> 01:12:49,246 So let's start with the diagonals. 1142 01:12:52,390 --> 01:12:54,660 The diagonals are all the same. 1143 01:12:54,660 --> 01:12:56,550 They are coefficients on this term. 1144 01:12:56,550 --> 01:12:57,970 This term goes into the diagonals. 1145 01:13:01,970 --> 01:13:02,730 Yeah. 1146 01:13:02,730 --> 01:13:04,976 This term goes into the diagonals. 1147 01:13:04,976 --> 01:13:06,370 And let me color that by blue. 1148 01:13:06,370 --> 01:13:08,101 This 2 over delta x squared-- 1149 01:13:08,101 --> 01:13:08,976 STUDENT: [INAUDIBLE]. 1150 01:13:08,976 --> 01:13:10,540 QIQI WANG: Negative. 1151 01:13:10,540 --> 01:13:12,304 Thank you. 1152 01:13:12,304 --> 01:13:16,160 Delta x square all the way to here minus 2 1153 01:13:16,160 --> 01:13:18,660 over delta x square. 1154 01:13:18,660 --> 01:13:25,915 Now, where does this go, Ui I plus 1? 1155 01:13:25,915 --> 01:13:30,270 Both with their upper diagonal goes over here. 1156 01:13:30,270 --> 01:13:33,970 It's 1 over delta x squared, 1 over delta x 1157 01:13:33,970 --> 01:13:38,360 squared' all the way to 1 over delta x square, 1158 01:13:38,360 --> 01:13:41,420 and here, 1 over delta x squared. 1159 01:13:41,420 --> 01:13:45,600 Because when i is equal to n, i plus 1 1160 01:13:45,600 --> 01:13:50,810 is actually equal to-- it's the same as ux1. 1161 01:13:50,810 --> 01:13:51,780 OK. 1162 01:13:51,780 --> 01:13:58,398 And lastly, let's fill in the-- OK. 1163 01:13:58,398 --> 01:14:01,930 Let's fill in this i minus 1. 1164 01:14:01,930 --> 01:14:04,526 This is i minus 1. 1165 01:14:04,526 --> 01:14:10,470 And fill in the i minus 1 term we have on the lower diagonal, 1166 01:14:10,470 --> 01:14:14,120 it's the same as the i plus 1 term, 1 over delta 1167 01:14:14,120 --> 01:14:16,470 x squared, 1 over delta x square, 1168 01:14:16,470 --> 01:14:18,640 and 1 over delta x square. 1169 01:14:18,640 --> 01:14:24,030 The first term is actually over here. 1170 01:14:24,030 --> 01:14:27,180 It is in order to get the second derivative for the first grid 1171 01:14:27,180 --> 01:14:27,680 point. 1172 01:14:27,680 --> 01:14:32,460 You have to graph all the way from the last grid point. 1173 01:14:32,460 --> 01:14:32,990 OK. 1174 01:14:32,990 --> 01:14:38,270 So this is the matrix form of the second order derivative. 1175 01:14:38,270 --> 01:14:39,510 OK. 1176 01:14:39,510 --> 01:14:41,460 So next class, we're going to look 1177 01:14:41,460 --> 01:14:45,750 at how the finite difference schemes converge 1178 01:14:45,750 --> 01:14:52,910 as we make the grid point more and make the spacing smaller, 1179 01:14:52,910 --> 01:14:57,780 and also stop to look at two-dimensional problems. 1180 01:14:57,780 --> 01:14:58,980 All right. 1181 01:14:58,980 --> 01:15:00,530 Thank you.