1 00:00:01,069 --> 00:00:06,809 This lecture is on solving equations on the computer. 2 00:00:06,809 --> 00:00:18,760 So far we used graphical methods and analytical methods to analyse x dot=f(x). 3 00:00:18,760 --> 00:00:24,970 We now consider some numerical integration methods of x dot = f(x). 4 00:00:24,970 --> 00:00:36,780 Here is a general problem statement given x dot = f(x) subject to the initial conditions 5 00:00:36,780 --> 00:00:46,730 x = x0 at t = t0, find a way to approximate the solution x of t. 6 00:00:46,730 --> 00:00:57,699 Let us outline Euler’s methods: Initially we are at x0 and the local velocity is f(x) 7 00:00:57,699 --> 00:00:59,120 not. 8 00:00:59,120 --> 00:01:06,560 If the phase point moves for a short time delta t. 9 00:01:06,560 --> 00:01:17,159 The new position is x(t0) plus delta t is approximately is equal to x0 plus f(x0) times 10 00:01:17,159 --> 00:01:23,729 delta t, which we call x. 11 00:01:23,729 --> 00:01:35,080 Then x(t0) plus delta t is approximately x1which is equal to x0 plus f(x0) times delta t. 12 00:01:35,080 --> 00:01:41,180 So, the new location is actually x1. 13 00:01:41,180 --> 00:01:58,289 And so, the new velocity is f(x1) and so x2 = x1+ f(x1) times delta t and so we continue 14 00:01:58,289 --> 00:01:59,920 like this. 15 00:01:59,920 --> 00:02:12,370 So, the general update rule is then x of n + 1 =xn + f(xn) times delta t. 16 00:02:12,370 --> 00:02:24,500 So let see how Euler’s scheme actually works plot x of t versus t we identify t0, t1 and 17 00:02:24,500 --> 00:02:33,860 t2 that is the exact solution we identified x0 which is the initial conditions corresponding 18 00:02:33,860 --> 00:02:41,520 to t0 highlight x(t1) and x(t2). 19 00:02:41,520 --> 00:02:53,920 The open dot show values x(tn) at discreet times tn = t0 + n times delta t. 20 00:02:53,920 --> 00:03:04,170 We then highlight values from Euler’s scheme x1 and x2 that comes from Euler’s scheme 21 00:03:04,170 --> 00:03:08,030 and we go ahead and connect the dots. 22 00:03:08,030 --> 00:03:19,150 The close dots show the approximate values given by Euler’s method note that delta 23 00:03:19,150 --> 00:03:26,850 t should be small else the approximation will actually be bad. 24 00:03:26,850 --> 00:03:33,560 So here is a simple-minded representation of Euler’s numerical schemes for approximating 25 00:03:33,560 --> 00:03:38,890 the solutions of a differential equations. 26 00:03:38,890 --> 00:03:44,810 So it is natural to ask, we can actually improve on the Euler method. 27 00:03:44,810 --> 00:03:55,700 The issue with the Euler method is that it estimates the derivatives only at the left-hand 28 00:03:55,700 --> 00:04:04,490 end of the time interval between tn and tn +1. 29 00:04:04,490 --> 00:04:15,400 A better way is to use the average derivative across the time interval. 30 00:04:15,400 --> 00:04:26,850 So here is the improved Euler method: using the Euler method take a trial step across 31 00:04:26,850 --> 00:04:41,280 the interval and we will get a trial value x tilde n +1 = xn + f(x)n times delta t. 32 00:04:41,280 --> 00:04:52,280 Then the average f(x)n and f(x) tilde n+1 and use it to make the real step across the 33 00:04:52,280 --> 00:04:54,440 interval. 34 00:04:54,440 --> 00:05:06,880 The method is as follows x tilde n+1 = xn + f(x)n times delta t, which is the trial 35 00:05:06,880 --> 00:05:23,960 step when xn+1 = xn + 1/2 of f(x)n + f(x) tilde n+1 times delta t and this is the actual 36 00:05:23,960 --> 00:05:26,030 step. 37 00:05:26,030 --> 00:05:39,550 This gives the smaller error e which is x(tn) - xn for a given step size delta t. 38 00:05:39,550 --> 00:05:48,880 Now in both the cases the error e tends to 0 as delta t tends to 0, but the error decreases 39 00:05:48,880 --> 00:05:55,550 faster for the improved Euler scheme. 40 00:05:55,550 --> 00:06:02,320 Note that the error is proportional to delta t in the Euler method and it is proportional 41 00:06:02,320 --> 00:06:07,960 to delta t squared in the improved Euler scheme. 42 00:06:07,960 --> 00:06:14,420 Now other numerical methods that one could use, now before mentioning them, we mention 43 00:06:14,420 --> 00:06:23,490 that in the language of numerical analysis the Euler method is a first order method, 44 00:06:23,490 --> 00:06:29,080 and the improved Euler method is a second order method. 45 00:06:29,080 --> 00:06:37,780 Higher order methods have been devised in the literature, but they actually involve 46 00:06:37,780 --> 00:06:41,650 additional computations. 47 00:06:41,650 --> 00:06:50,840 In practice a very good scheme is the fourth order Runge Kutta scheme. 48 00:06:50,840 --> 00:06:59,330 This was actually developed by German mathematicians working in approximately 1900. 49 00:06:59,330 --> 00:07:14,620 So the objective is to find the xn+1 in terms of xn, so xn+1 = xn+ one upon six times k1 50 00:07:14,620 --> 00:07:29,950 + 2 times k2 + 2 times k3 + k4, where k1 is f(xn) time delta t, k2 is f(x)n +1/2 k1 times 51 00:07:29,950 --> 00:07:47,630 delta t, k3= f(xn) + 1/2 k2 times delta t and k4 = f(xn) + k3 times delta t. 52 00:07:47,630 --> 00:07:57,460 Now usually this gives us very accurate results without having to rely on very small step 53 00:07:57,460 --> 00:08:01,389 sizes delta t. 54 00:08:01,389 --> 00:08:07,460 This lecture was centred around using the computer to solve our differential equations 55 00:08:07,460 --> 00:08:09,270 using numerical methods. 56 00:08:09,270 --> 00:08:14,990 We seen variety of analytical method to develop intuition about nonlinear equations of the 57 00:08:14,990 --> 00:08:18,800 form x dot = f(x). 58 00:08:18,800 --> 00:08:24,669 But it can sometimes rather difficult to develop intuition purely analytically because non-linearity 59 00:08:24,669 --> 00:08:26,930 may be just very, very strange. 60 00:08:26,930 --> 00:08:33,190 So, it is perfectly fare and it is perfectly sensible to actually use the computer to actually 61 00:08:33,190 --> 00:08:38,380 simulate the differential equation to actually develop some insights about how the equation 62 00:08:38,380 --> 00:08:39,710 would actually behave. 63 00:08:39,710 --> 00:08:42,349 So to that end, we highlighted couple of numerical schemes. 64 00:08:42,349 --> 00:08:49,730 We started off with very simple Euler methods, we introduced you to the improved Euler method 65 00:08:49,730 --> 00:08:56,190 and we also mentioned that in practice a good compromise between accuracy and efficiency 66 00:08:56,190 --> 00:09:00,760 is actually obtained by the fourth order Runge Kutta method. 67 00:09:00,760 --> 00:09:05,860 Now interestingly these two mathematicians, German mathematicians actually devised the 68 00:09:05,860 --> 00:09:11,310 scheme in 1901 that was way before computers, were actually devised. 69 00:09:11,310 --> 00:09:18,940 In fact, computers played a extremely crucial role in the popularisation of nonlinear dynamics 70 00:09:18,940 --> 00:09:25,540 and that was done by very famous paper by Murray 1963, where he had numerical computations 71 00:09:25,540 --> 00:09:29,700 of a model, that he has devised for atmospheric dynamics. 72 00:09:29,700 --> 00:09:33,740 To show that it had all kind of very strange behaviour. 73 00:09:33,740 --> 00:09:41,070 So, the lesson from this particular lecture is that numerical schemes and computer cannot 74 00:09:41,070 --> 00:09:43,760 be a substitute for an analysis. 75 00:09:43,760 --> 00:09:47,260 But in fact, there are excellent complements to the analysis.