Integrating with Modified Euler's MethodDate: 08/13/2007 at 01:35:12 From: Saji Subject: modified Euler’s method Using modified Euler’s method find the value of y at x = 0.2 with h = 0.1 where dy/dx = 1 - y with y(0) = 0. Date: 08/15/2007 at 08:06:47 From: Doctor Luis Subject: Re: modified Euler’s method Hi Saji, To get you started, first look at this link Euler Method http://en.wikipedia.org/wiki/Euler_integration Basically, the Euler integration method gives you a way to obtain the values of y(x) at specific points x, based on the differential equation dy/dx = f(x,y) subject to an appropriate initial condition y_0 (i.e. the value of y(x) at x_0). As a numerical approximation, you can approximate the derivative by a forward difference as follows: y'(x_n) ~ (y_{n+1} - y_n)/h Additionally, from the assumption that y satisfies the differential equation y'(x_n) = f(x_n,y_n) you can obtain the following relation between successive y's: y_{n+1} = y_n + h * f(x_n,y_n) This formula makes sense if you think of y as distance, x as time, and dy/dx = f as speed. So, in that sense, this formula says that your new position (y_{n+1}) is equal to the old position (y_n) plus whatever distance you traveled in a time interval equal to h. Successive values y_0, y_1, y_2, ... may be obtained in that manner, in time increment values of h. In your case, of course, x_0 = 0, y_0 = 0, f(x,y) = 1 - y, but I'll keep the discussion general so you'll be able to solve similar problems in the future. With a spacing h, you can see that x_n = x_0 + n * h, so that x_1 = h = 0.1 x_2 = 2h = 0.2 The y_n's are defined such that y_0 = y(x_0) y_1 = y(x_1) y_2 = y(x_2) Performing the Euler integration is done as follows: y_1 = y_0 + h * f(x_0, y_0) y_2 = y_1 + h * f(x_1, y_1) Note that, just as y_0 is needed for calculating y_1, you'll need to find y_1 in order to find y_2. However, that's not the answer to your problem just yet. The problem asks you to use the *modified* Euler method. To explain what that is, let's go back to our speed analogy y_{n+1} = y_n + h * f(x_n,y_n) You'll note that the time interval covered is from x_n to x_{n+1}, and that the speed is evaluated at the *start* of this time interval. Well, that doesn't sound very accurate, right? After all, the speed dy/dx is changing throughout the time interval. Using the speed at the beginning of the interval might overshoot or undershoot the correct value of the distance. Wouldn't it be better if we used the value of the speed evaluated at the midpoint of the time interval? That sounds like a better estimate of the average speed during the interval, right? Well, that's exactly what the modified Euler integration method uses. In other words, the modified equation we want is: y_{n+1} = y_n + h * f(x_{n+1/2}, y_{n+1/2}) Applying this to your problem will give you y_1 = y_0 + h * f(x_{1/2}, y_{1/2}) y_2 = y_1 + h * f(x_{3/2}, y_{3/2}) Oops. To find y_1 from y_0 we need the value of y_{1/2} first. Well, we only need an estimate, so we can apply the regular Euler method first, but with a half-step of h/2 instead: y_{1/2} = y_0 + (h/2) * f(x_0, y_0) And that gives us y_{1/2}! But what about y_{3/2}, you ask? Well, that's a full-step away from y_{1/2}, so now you can use the more accurate modified method to find an estimate for y_{3/2}, where the "velocity" term is evaluated at the midpoint "time" x_1. To summarize the modified Euler integration method: First take a half-step of h/2 with the regular method y_{1/2} = y_0 + (h/2) * f(x_0, y_0) Next, take full steps by using the modified method making sure to evaluate the "velocity" terms at the appropriate midpoint of each interval. y_{1} = y_0 + h * f(x_{1/2}, y_{1/2}) y_{3/2} = y_{1/2} + h * f(x_{1}, y_{1}) y_{2} = y_{1} + h * f(x_{3/2}, y_{3/2}) And that's it! I hope it all makes sense. If it looks complicated, just take it a step at a time. Just don't forget the following basic definitions: First, we have the "times" x_0 = 0 x_{1/2} = (1/2)h x_1 = h x_{3/2} = (3/2)h x_2 = 2h and, one at a time, find the corresponding "distances" y_0 = y(x_0) y_{1/2} = y(x_{1/2}) y_1 = y(x_1) y_{3/2} = y(x_{3/2}) y_2 = y(x_2) Let us know if you have any more questions! - Doctor Luis, The Math Forum http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/