This file is part of a distribution of the Calculus Applets website (http://www.calculusapplets.com) which has been reformatted for the purposes of this OpenCourseware course.

How can one draw a solution for a differential equation? If you can solve the differential equation exactly, then you can just graph a solution through a particular point. However, many differential equations cannot be solved exactly, so we need a numerical method to sketch a solution. Euler's method is one such technique.

Try the following:

- The applet shows the slope field for
*dy/dx*=*x*. To sketch a solution curve, Euler's method starts at a given point (the magenta point in this example). You then compute the slope at this point (zero in this case), then move along a line with this slope for a specific amount of*x*(called*deltaT*in this applet, and set to 1 for this example). To see this, click the Next button at the bottom of the applet. You should see a magenta line segment going from (0,0) to (1,0). Euler's method then repeats the process by finding the slope at this new location (the new slope is 1), then moving along a line with slope of 1 for 1 unit of*x*. Click Next to see the second segment. Euler's method then repeats this process of finding a slope and sketching a segment to a new point to draw out the curve. You can see an animated version of this process by clicking the Start button. This will draw 10 segments, then reset. You can Pause at any time and use the Next and Prev buttons. There are also two choice options, one which controls looping (set to Play Once by default) and the other which controls the animation speed (set to Slow by default).

Notice that the magenta curve drawn by Euler's method is roughly the same shape as the blue solution, but isn't very good. We can improve this by changing the*deltaT*value to use smaller*x*steps. Edit the*delta**T*to be 0.5 instead of 5, then rerun the animation (or click Next a few times to draw part of the curve). The curve drawn with Euler's method is much closer. Try 0.1 for*deltaT*, but you will need to click Zoom In to see the magenta curve, since only 10 segments are drawn. Now the curve is much closer to the blue solution. Note that the blue curve is actually drawn with a different algorithm (4th order Runge-Kutta), so it is also an approximation to the real curve, but generally a more accurate one that Euler's method. Euler's method can also be used to extend the curve in the negative*x*direction, using the same basic idea.

- Select the second example from the drop down menu, showing
*dy/dx*=*y*sin(*x*). Click Next 10 times or click Start to draw the curve using Euler's method. Note that with a step size of 1, the Euler curve gets close to the*x*-axis, where the slope is very shallow, and then gets "stuck" there. Change*deltaT*to 0.5 and notice that now the curve doesn't stray so far and comes back up. One of the difficulties with numerical methods is that they can sometimes get stuck near certain values when the step size is too large. Note that if you zoom out, the blue curve abruptly ends; this is an artifact of the algorithm used to graph the solution.

- Select the third example, showing
*dy/dx*=1/*y*. We will find out later that the solution family is*x*=*y*²/2 +*C*, which look like parabolas opening up towards the right (i.e., these are not functions). Click Next and watch what happens. Here, the slope is very steep near the starting point, so the Euler curve takes off too fast. Changing the step size to 0.5 improves things, but still causes problems. Like example 2, where the slope was very shallow, here a very steep slope causes trouble for the algorithm. You may also notice that the blue curve doesn't look much like a parabola, either. We will look at this issue in the next example.

- Select the fourth example, showing
*dy/dx*=-1/*y*. The solutions will be parabolas opening in the opposite direction. Obviously the blue curve is really having troubles! Click Next to look at the first Euler segment. Since the slope at the starting point is negative, the first segment slopes down. Click Next again and you can see the problem. The slope is positive so the next segment steps back up, but the real curve should keep going down and to the left! The problem is that Euler's methods steps along the*x*axis, assuming it is graphing a function. Here, the solution is not a function so the numerical methods get very confused. Click Next a few more times to see the curve jump up and down everytime it cross the*x*-axis. This is the source for the jagged curves you have seen on some differential equation graphs where the solution is not a function.

For more information on rights and downloading, refer to http://www.calculusapplets.com/download.html.

© Copyright 2001 David J. Eck

© Copyright 2007 Thomas S. Downey

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

You must cause any files that you modify to carry prominent notices stating that you changed the files and the date of any change, and modified files must be put into a Java package different from edu.hws.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Citation: tdowney. (2009, August 18). Euler\'s Method. Retrieved November 01, 2014, from Notre Dame OpenCourseWare Web site: http://ocw.nd.edu/mathematics/calculus-ii-for-business/calculus-applets-website/eulers-method.

Copyright 2012,
Thomas Downey.
This work is licensed under a
Creative Commons Attribution 3.0 License.