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.
1. dy/dx = x
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 deltaT 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.
2. dy/dx = y*sin(x)
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.
3. dy/dx = 1/y
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.
4. dy/dx = -1/y
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 every time 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.
Other 'Differential Equations' topics
Derived from the work of Thomas S. Downey under a Creative Commons Attribution 3.0 License.