To add comments or start new threads please go to the full version of: The Euler Method
PhysOrgForum Science, Physics and Technology Discussion Forums > General Sci-Tech Discussions > Homework Help

professor andy
Can anyone explain to me the basics of this method?

..pretty please?? rolleyes.gif
amac
I'll try a quick explanation.

Euler's method is a way of approximating values on a curve if you are only given an initial value and the derivative of the curve. From my experience, it's used in equations where you are given the derivative as a function of the curve's value, for example y'(x) = y +3x. You might wonder why we don't just integrate to find the exact answer, but some functions you either don't know how to integrate or they can't be integrated at all.

The basic idea is that you take a starting point on the curve (which is given to you), and use the tangent line (derivative) at that point to approximate another point on the curve that is close by. You then use the point you just found as the starting point and repeat the process again and again until you've estimated the point you are looking for.

User posted image

When I was learning Euler's method I didn't really get it until I saw some pictures of what was happening. Do a Google image search for Euler's Method: it should help you to understand the concept.

Now let's get a little more into the math. We'll use the differential equation y'(x) = 2y +x. Let's say we are given the point on y(0)=0 and we want to approximate the point at x=4 by using two steps to get there. That means each step is going to be 2 apart on the x axis. Now we'll calculate the first point on our way to x=4, which for steps of size 2 will be at x=2. Here's the important part: because the derivative is the slope of the curve, we can say that it is represented by rise over run, or change in y over a change in x. This is basic graphing stuff. So if we take the derivative(delta y / delta x) and multiply it by the step we're taking, we will get the change in y of the function. This is because each step is just a change in x, so we essentially have (delta y / delta x) * (delta x) = delta y. For the example function we picked, the point y(2) would be equal to it's initial value plus the change in height of the function, so y(2) = 0 + 2*y'(0) = 2*(0) = 0. We now have the point (2,0). To approximate the value of y(4), we repeat the process with our new numbers: y(4) = y(2) + 2*y'(2) = 0 + 2*(0 + 2) = 4.

The general formula you use is y(x+h) = y(x) + h*y'(x), where h is the size of each step you take. As h becomes smaller, the approximation becomes more accurate. To keep track of all of your iterations, it helps to create a chart of all of your information.

I realize that might be a little unclear, but try and understand the general idea before you attempt the math. As I've said, pictures really help. As always, feel free to ask for any clarifications.

Sorry, this wasn't as quick of an explanation as I was aiming for. Oh well.
professor andy
I have been over this a lot, and I can understand it. I'm trying to write a program in VisualBasic 6 to calculate the number of parent nuclei after some 520000 years and put that in a neat little box on the interface..

But it's MIND NUMBING!!

mad.gif
AlphaNumeric
Why not just use N(t) = N_0 exp(-kt) where k is the decay constant and N_0 the initial number of nuclei? No need to use the Euler method, since the system (dN/dt = -kN) is integrable.
professor andy
I have to use the Euler method, and then the taylor series up to 3rd order and then do it analytically, then compair the results to see how accurite they are..

This is if I could write it to start with! Lol..
Trippy
QUOTE (professor andy+Aug 22 2007, 12:11 AM)
I have to use the Euler method, and then the taylor series up to 3rd order and then do it analytically, then compair the results to see how accurite they are..

This is if I could write it to start with! Lol..

Good luck with that - I've never had a whole lot of luck trying to make computers understand what are essentially graphical methods - at one point I tried using a combination of... I think it was the Newton-Raphson(sp?) method and binary sorting to find the roots of secondary primes, but that never quite wprked, and I never quite worked out what the problem was.
AlphaNumeric
You have that

dN/dt = -kN

To use the Euler method you need to turn this into a difference equation, not a differential equation.

You're going from t=0 to t=T in n steps, so your 'dt' = T/n. The differential equation is then discretised into :

[N(t_m+1)-N(t_m)]/dt = -kN(t_m)

=> N(t_m+1) = -k*N(t_m)*dt + N(t_m)
=> N(t_m+1) = (1-kT/n)N(t_m)

Now you just write a program to do that iteratively. Given N(t_0) = N(t=0) = N_0, the initial condition, you can then work out N(t_1) = N(dt) = (1-kT/n)N(0). Then from that N(t_2) = N(2*dt) from N(dt) etc.

Varying the value of n, the total number of iterations (or time divisions) will alter the accuracy of the result. If you're doing this as some kind of project, I'd recommend investigating that (obviously the bigger n the more accurate the results).

For such a simple dynamical system n won't have too much an effect. For complicated or highly sensitive systems, you'd need to make n unfeasably huge. Then you have to consider more advanced discretisation methods, such as Runge-Kutta. That one's vastly superior to the Euler method.

Yep, I had to do such projects once too...
professor andy
Thank you for all your help. I mannaged to pass this module, found out last night.

But I failed two others, and my continuation with Physics at university hangs in the ballance... sad.gif
professor andy
Oh!

Just for the sake of keeping you up-to-date, I failed one of those modules by a SINGLE mark. So I had to spend a year repeating it while working in a popular nightclub in Belfast. Which to be fair I quite enjoyed. biggrin.gif

I shall now return in September and continue my physics degree where I left off..

-happy days!
PhysOrg scientific forums are totally dedicated to science, physics, and technology. Besides topical forums such as nanotechnology, quantum physics, silicon and III-V technology, applied physics, materials, space and others, you can also join our news and publications discussions. We also provide an off-topic forum category. If you need specific help on a scientific problem or have a question related to physics or technology, visit the PhysOrg Forums. Here you’ll find experts from various fields online every day.
To quit out of "lo-fi" mode and return to the regular forums, please click here.