Numerical Methods - Euler Method Summary
Numerical Methods for Solving Differential Equations
Euler's Method
Theoretical Introduction
(continued fromÌýlast page...)
Summary of Euler's Method
In order to use Euler's Method to generate a numerical solution to an initial value problem of the form:
²â′Ìý=Ìýf(³æ,Ìý²â)
y(xo)Ìý=Ìýyo
we decide upon what interval, starting at the initial condition, we desire to find the solution. We chop this interval into small subdivisions of lengthÌýh. Then, using the initial condition as our starting point, we generate the rest of the solution by using the iterative formulas:
xn+1Ìý=ÌýxnÌý+Ìýh
yn+1Ìý=ÌýynÌý+ÌýhÌý´Ú(xn,Ìýyn)
to find the coordinates of the points in our numerical solution. We terminate this process when we have reached the right end of the desired interval.
A Preliminary Example
Just to get a feel for the method in action, let's work a preliminary example completely by hand. Say you were asked to solve the initial value problem:
²â′Ìý=ÌýxÌý+Ìý2y
y(0)Ìý=Ìý0
numerically, finding a value for the solution atÌýxÌý=Ìý1, and using steps of sizeÌýhÌý=Ìý0.25.
Applying the Method
Clearly, the description of the problem implies that the interval we'll be finding a solution on is [0,1]. The differential equation given tells us the formula forÌýf(³æ,Ìý²â) required by the Euler Method, namely:
f(³æ,Ìý²â)Ìý=ÌýxÌý+Ìý2y
and the initial condition tells us the values of the coordinates of our starting point:
- xoÌý=Ìý0
- yoÌý=Ìý0
We now use the Euler method formulas to generate values forÌýx1Ìý²¹²Ô»åÌýy1.
°Õ³ó±ðÌýx-iteration formula, withÌýnÌý=Ìý0 gives us:
x1Ìý=ÌýxoÌý+Ìýh
or:
x1Ìý=Ìý0Ìý+Ìý0.25
So:
x1Ìý=Ìý0.25
And theÌýy-iteration formula, withÌýnÌý=Ìý0 gives us:
y1Ìý=ÌýyoÌý+ÌýhÌýf(xo,Ìýyo)
or:
y1Ìý=ÌýyoÌý+ÌýhÌý(xoÌý+Ìý2yo)
or:
y1Ìý=Ìý0Ìý+Ìý0.25Ìý(0Ìý+Ìý2*0)
So:
y1Ìý=Ìý0
Summarizing, the second point in our numerical solution is:
- x1Ìý=Ìý0.25
- y1Ìý=Ìý0
We now move on to get the next point in the solution, (x2,Ìýy2).
°Õ³ó±ðÌýx-iteration formula, withÌýn=1 gives us:
x2Ìý=Ìýx1Ìý+Ìýh
or:
x2Ìý=Ìý0.25Ìý+Ìý0.25
So:
x2Ìý=Ìý0.5
And theÌýy-iteration formula, withÌýnÌý=Ìý1 gives us:
y2Ìý=Ìýy1Ìý+ÌýhÌýf(x1,Ìýy1)
or:
y2Ìý=Ìýy1Ìý+ÌýhÌý(x1Ìý+Ìý2y1)
or:
y2Ìý=Ìý0Ìý+Ìý0.25Ìý(0.25Ìý+Ìý2*0)
So:
y2Ìý=Ìý0.0625
Summarizing, the third point in our numerical solution is:
- x2Ìý=Ìý0.5
- y2Ìý=Ìý0.0625
We now move on to get the fourth point in the solution, (x3,Ìýy3).
°Õ³ó±ðÌýx-iteration formula, withÌýnÌý=Ìý2 gives us:
x3Ìý=Ìýx2Ìý+Ìýh
or:
x3Ìý=Ìý0.5Ìý+Ìý0.25
So:
x3Ìý=Ìý0.75
And theÌýy-iteration formula, withÌýnÌý=Ìý2 gives us:
y3Ìý=Ìýy2Ìý+ÌýhÌýf(x2,Ìýy2)
or:
y3Ìý=Ìýy2Ìý+ÌýhÌý(x2Ìý+Ìý2y2)
or:
y3Ìý=Ìý0.0625Ìý+Ìý0.25Ìý(0.5Ìý+Ìý2*0.0625)
So:
y3Ìý=Ìý0.21875
Summarizing, the fourth point in our numerical solution is:
- x3Ìý=Ìý0.75
- y3Ìý=Ìý0.21875
We now move on to get the fifth point in the solution, (x4,Ìýy4).
°Õ³ó±ðÌýx-iteration formula, withÌýnÌý=Ìý3 gives us:
x4Ìý=Ìýx3Ìý+Ìýh
or:
x4Ìý=Ìý0.75Ìý+Ìý0.25
So:
x4Ìý=Ìý1
And theÌýy-iteration formula, withÌýnÌý=Ìý3 gives us:
y4Ìý=Ìýy3Ìý+ÌýhÌýf(x3,Ìýy3)
or:
y4Ìý=Ìýy3Ìý+ÌýhÌý(x3Ìý+Ìý2y3)
or:
y4Ìý=Ìý0.21875Ìý+Ìý0.25Ìý(0.75Ìý+Ìý2*0.21875)
So:
y4Ìý=Ìý0.515625
Summarizing, the fourth point in our numerical solution is:
- x4Ìý=Ìý1
- y4Ìý=Ìý0.515625
We could summarize theÌýresultsÌýof all of our calculations in a tabular form, as follows:
n | xn | yn |
---|---|---|
0 | 0.00 | 0.000000 |
1 | 0.25 | 0.000000 |
2 | 0.50 | 0.062500 |
3 | 0.75 | 0.218750 |
4 | 1.00 | 0.515625 |
A question you should always ask yourself at this point of using a numerical method to solve a problem, is "How accurate is my solution?" Sadly, the answer is "Not very!" This problem can actually be solved without resorting to numerical methods (it's linear). The true solution turns out to be:
yÌý=Ìý0.25Ìýe2xÌý- 0.5ÌýxÌý-Ìý0.25
If we use this formula to generate a table similar to the one above, we can see just how poorly our numerical solution did:
x | y |
---|---|
0.00 | 0.000000 |
0.25 | 0.037180 |
0.50 | 0.179570 |
0.75 | 0.495422 |
1.00 | 1.097264 |
We can get an even better feel for the inaccuracy we have incurred if we compare the graphs of the numerical and true solutions, as shown here:
The numerical solution gets worse and worse as we move further to the right. We might even be prompted to ask the question "What good is a solution that is this bad?" The answer is "Very little good at all!" So should we quit using this method? No!ÌýThe reason our numerical solution is so inaccurate is because our step-size is so large.ÌýTo improve the solution, shrink the step-size!
By the way, the reason I used such a large step size when we went through this problem is because we were working it by hand. When we move on to using the computer to do the work, we needn't be so afraid of using tiny step-sizes.
To illustrate that Euler's Method isn't always this terribly bad, look at the following picture, made for exactly the same problem, only using a step size ofÌýhÌý=Ìý0.02:
As you can see, the accuracy of this numerical solution is much higher than before,Ìýbut so is the amount of work needed!ÌýLook at all thoseÌýred points! Can you imagine calculating the coordinates of each of them by hand?
I think that we have adequately demonstrated the concepts underlying the Euler's Method algorithm. We have seen the derivation of the required formulas from both a graphical and a formulaic point-of-view. We've even gone through an example of using the method for a small number of points. Now it's time to get out the big guns! This method is one that truly belongs on a computer!
Let's nowÌýgo and seeÌýhow we would implement these ideas inÌýMathematica.