1 00:00:05,580 --> 00:00:09,950 PROFESSOR: Here is the classical Runge-Kutta method. 2 00:00:09,950 --> 00:00:14,510 This was, by far and away, the world's most popular 3 00:00:14,510 --> 00:00:22,790 numerical method for over 100 years for hand computation 4 00:00:22,790 --> 00:00:26,240 in the first half of the 20th century, 5 00:00:26,240 --> 00:00:29,030 and then for computation on digital computers 6 00:00:29,030 --> 00:00:32,150 in the latter half of the 20th century. 7 00:00:32,150 --> 00:00:38,300 I suspect it's still in use today. 8 00:00:38,300 --> 00:00:42,240 You evaluate the function four times per step, 9 00:00:42,240 --> 00:00:45,080 first in the beginning of the interval. 10 00:00:45,080 --> 00:00:48,290 And then use that to step into the middle of the interval, 11 00:00:48,290 --> 00:00:50,360 to get s2. 12 00:00:50,360 --> 00:00:54,990 Then you use s2 to step into the middle of the interval again. 13 00:00:54,990 --> 00:00:59,720 And evaluate the function there again to get s3. 14 00:00:59,720 --> 00:01:03,350 And then use s3 to step clear across the interval, 15 00:01:03,350 --> 00:01:06,150 and get s4. 16 00:01:06,150 --> 00:01:13,880 And then take a combination of those four slopes, 17 00:01:13,880 --> 00:01:17,480 weighting the two in the middle more heavily, 18 00:01:17,480 --> 00:01:20,580 to take your final step. 19 00:01:20,580 --> 00:01:24,040 That's the classical Runge-Kutta method. 20 00:01:28,560 --> 00:01:33,170 Here's our MATLAB implementation. 21 00:01:33,170 --> 00:01:37,290 And we will call it ODE4, because it 22 00:01:37,290 --> 00:01:42,270 evaluates to function four times per step. 23 00:01:42,270 --> 00:01:47,120 Same arguments, vector y out. 24 00:01:47,120 --> 00:01:54,020 Now we have four slopes-- s1 at the beginning, s2 halfway 25 00:01:54,020 --> 00:01:57,630 in the middle, s3 again in the middle, 26 00:01:57,630 --> 00:02:01,600 and then s4 at the right hand. 27 00:02:01,600 --> 00:02:09,500 1/6 of s1, 1/3 of s2, 1/3 of s3, and 1/6 of s4 28 00:02:09,500 --> 00:02:12,480 give you your final step. 29 00:02:12,480 --> 00:02:15,595 That's the classical Runge-Kutta method. 30 00:02:20,660 --> 00:02:25,740 Carl Runge was a fairly prominent German mathematician 31 00:02:25,740 --> 00:02:30,290 and physicist, who published this method, 32 00:02:30,290 --> 00:02:35,200 along with several others, in 1895. 33 00:02:35,200 --> 00:02:39,530 He produced a number of other mathematical papers 34 00:02:39,530 --> 00:02:42,150 and was fairly well known. 35 00:02:42,150 --> 00:02:47,690 Martin Kutta discovered this method independently 36 00:02:47,690 --> 00:02:52,140 and published it in 1901. 37 00:02:52,140 --> 00:02:59,690 He is not so nearly well known for anything else. 38 00:02:59,690 --> 00:03:03,530 I'd like to pursue a simple model of combustion. 39 00:03:03,530 --> 00:03:09,700 Because the model has some important numerical properties. 40 00:03:09,700 --> 00:03:13,040 If you light a match, the ball of flame 41 00:03:13,040 --> 00:03:17,090 grows rapidly until it reaches a critical size. 42 00:03:17,090 --> 00:03:20,240 Then the remains at that size, because the amount of oxygen 43 00:03:20,240 --> 00:03:24,380 being consumed by the combustion in the interior of the ball 44 00:03:24,380 --> 00:03:27,210 balances the amount available through the surface. 45 00:03:31,120 --> 00:03:34,760 Here's the dimensionless model. 46 00:03:34,760 --> 00:03:40,440 The match is a sphere, and y is its radius. 47 00:03:40,440 --> 00:03:45,660 The y cubed term is the volume of the sphere. 48 00:03:45,660 --> 00:03:50,540 And the y cubed accounts for the combustion in the interior. 49 00:03:53,370 --> 00:03:57,000 The surface of the sphere is proportional y squared. 50 00:03:57,000 --> 00:04:00,340 And the y squared term accounts for the oxygen that's 51 00:04:00,340 --> 00:04:03,160 available through the surface. 52 00:04:03,160 --> 00:04:05,700 The critical parameter, the important parameter, 53 00:04:05,700 --> 00:04:11,410 is the initial radius, y0, y naught. 54 00:04:11,410 --> 00:04:15,480 The radius starts at y0 and grows 55 00:04:15,480 --> 00:04:19,690 until the y cubed and y squared terms 56 00:04:19,690 --> 00:04:24,980 balance each other, at which point the rate of growth is 0. 57 00:04:24,980 --> 00:04:27,710 And the radius doesn't grow anymore. 58 00:04:27,710 --> 00:04:29,900 We integrate over a long time. 59 00:04:29,900 --> 00:04:34,260 We integrate over a time that's inversely proportional 60 00:04:34,260 --> 00:04:36,620 to the initial radius. 61 00:04:36,620 --> 00:04:37,385 That's the model. 62 00:04:41,340 --> 00:04:43,620 Here's an animation. 63 00:04:43,620 --> 00:04:46,880 We're starting with a small flame here, 64 00:04:46,880 --> 00:04:49,422 a small spherical flame. 65 00:04:49,422 --> 00:04:53,020 You'll just see a small radius there. 66 00:04:53,020 --> 00:04:57,300 The time and the radius are shown at the top of the figure. 67 00:04:57,300 --> 00:04:59,990 It's beginning to grow. 68 00:04:59,990 --> 00:05:04,240 When time gets to 50, we're halfway through. 69 00:05:04,240 --> 00:05:07,890 The flame sort of explodes, and then gets up 70 00:05:07,890 --> 00:05:14,620 the radius 1, at which time the two terms balance each other. 71 00:05:14,620 --> 00:05:18,240 And the flame stops growing. 72 00:05:18,240 --> 00:05:20,170 It's still growing slightly here, 73 00:05:20,170 --> 00:05:24,810 although you can't see it on this this scale. 74 00:05:33,780 --> 00:05:37,750 Let's set this up for Runge-Kutta. 75 00:05:37,750 --> 00:05:41,550 The differential equation is y prime is y 76 00:05:41,550 --> 00:05:44,740 squared minus y cubed. 77 00:05:44,740 --> 00:05:52,470 Starting at zero, with the critical initial radius, 78 00:05:52,470 --> 00:05:56,930 I'm going to take to be 0.01. 79 00:05:56,930 --> 00:06:00,380 That means we're going to integrate out to two over y0 80 00:06:00,380 --> 00:06:04,910 out to time 200. 81 00:06:04,910 --> 00:06:10,260 I'm going to choose the step size to take 500 steps. 82 00:06:10,260 --> 00:06:12,896 I'm just going to pick that somewhat arbitrarily. 83 00:06:16,650 --> 00:06:19,490 OK, now I'm ready to use ODE4. 84 00:06:19,490 --> 00:06:21,060 And I'll store the results in y. 85 00:06:23,790 --> 00:06:27,720 And it goes up to 1. 86 00:06:27,720 --> 00:06:29,100 I'm going to plot the results. 87 00:06:29,100 --> 00:06:32,600 So here's the values of t I need. 88 00:06:32,600 --> 00:06:33,715 And here's the plot. 89 00:06:38,870 --> 00:06:43,360 Now, you can see the flame starts to grow. 90 00:06:43,360 --> 00:06:44,950 It grows rather slowly. 91 00:06:44,950 --> 00:06:47,970 And then halfway through the time interval, 92 00:06:47,970 --> 00:06:51,020 it's sort of explodes and goes up quickly, 93 00:06:51,020 --> 00:06:55,670 until it reaches a radius of 1, and then stays here. 94 00:06:55,670 --> 00:06:59,620 Now this transition period is fairly narrow. 95 00:06:59,620 --> 00:07:05,020 And we're going to continue to study this problem. 96 00:07:05,020 --> 00:07:08,690 And is this transition area which 97 00:07:08,690 --> 00:07:15,490 is going to provide a challenge for the numerical methods. 98 00:07:15,490 --> 00:07:17,740 Now here, we just went through it. 99 00:07:17,740 --> 00:07:21,620 We had a step size h, that we picked pretty arbitrarily. 100 00:07:21,620 --> 00:07:24,540 And we just generated these values. 101 00:07:24,540 --> 00:07:30,623 We have really little idea how accurate these numbers are. 102 00:07:30,623 --> 00:07:32,350 They look OK. 103 00:07:32,350 --> 00:07:35,540 But how accurate are they? 104 00:07:35,540 --> 00:07:40,010 This is the critical question about the 105 00:07:40,010 --> 00:07:43,870 about the classical Runge-Kutta method. 106 00:07:43,870 --> 00:07:47,875 How reliable are the values we have here in our graph? 107 00:07:54,750 --> 00:07:58,820 I have four exercises for your consideration. 108 00:07:58,820 --> 00:08:03,100 If the differential equation does not involve y, 109 00:08:03,100 --> 00:08:06,520 then this solution is just an integral. 110 00:08:06,520 --> 00:08:09,920 And the Runge-Kutta method becomes a classic method 111 00:08:09,920 --> 00:08:12,470 of numerical integration. 112 00:08:12,470 --> 00:08:14,790 If you've studied such methods, then you 113 00:08:14,790 --> 00:08:17,045 should be able to recognize this method. 114 00:08:22,140 --> 00:08:27,810 Number. two-- find the exact solution of y prime equals 1 115 00:08:27,810 --> 00:08:31,660 plus y squared, with y of 0 equals zero. 116 00:08:31,660 --> 00:08:36,510 And then see what happens with ODE4, when you try and solve it 117 00:08:36,510 --> 00:08:39,539 on the interval from t from 0 to 2. 118 00:08:44,030 --> 00:08:48,710 Number three- what happens if the length of the interval 119 00:08:48,710 --> 00:08:52,440 is not exactly divisible by the step size? 120 00:08:52,440 --> 00:08:58,880 For example, if t final is pi, and the step size is 0.1. 121 00:08:58,880 --> 00:09:01,150 Don't try and fix this. 122 00:09:01,150 --> 00:09:03,950 It's just one of the hazards of a fixed step size. 123 00:09:07,550 --> 00:09:13,140 And finally, exercise four-- investigate the flame problem 124 00:09:13,140 --> 00:09:19,250 with an initial radius of 1/1,000. 125 00:09:19,250 --> 00:09:24,910 For what value of t does the radius 126 00:09:24,910 --> 00:09:29,600 reach 90% of its final value?