We can use the idea behind slope fields to find approximate solutions to differential equations. In fact, when the computer generated solutions on the slope field in the last section, it was using a variation of Euler's Method to do so. Okay, so the question is: if we don't know exactly what the solution is, how can we still draw it? The key is that what we do know is the slope at any given point, and we know the starting point (we have to be given an initial condition in order to be able to do this).
Pretend that you're an investigator who's tracking a criminal. You know where he was last seen, and you have gotten inside his head to the point that you can predict at any point which way he would go if he were there. What would you do? Of course, you'd head to the criminal's last known location, and start heading the way that he would. Be careful, though; he might change direction, so if you just keep going straight forever, you'll get lost very quickly.
Okay, back up again to the criminal's last known location. Now start heading off in the direction that he would, but don't go very far. After a few steps, stop and reconsider, then head off in the direction he would go from this location. If you keep doing this process of going in the right direction, then stopping and recalibrating, you'll have a good chance of following at least close to the path of the criminal.
This illustrates the idea behind Euler's Method. We know where the solution begins and we know exactly what direction it would go at any point. We can put these two together to draw an approximate solution. The shorter our steps (meaning the more often we stop to recalibrate), the better our approximation will be, but that takes more computing power, so there's a tradeoff there. Essentially, though, we're approximating the solution with a series of short linear segments, as shown here.
We're given two things: (the differential equation; we'll use instead of but it's nothing different) and (the initial condition). We'll also have a step size which will either be given or we'll have to choose it. Our starting point, then is and all we need is a way to get from one point to the next. This is the algorithm.
Getting the next value is the easy part. This is just the previous value plus the step size:
The tricky part, then, is finding the next value from the previous one; for this, we turn to the slope. Remember that slope is rise over run:
In general, we find each point using the previous point:
Use Euler's Method with a step size of to estimate if
I like to build a table for these problems:
What we've inserted so far simply comes from the initial condition: when and Next, we can easily go down and add all the values that we need (up through ) just by adding each time we add a row:
For the rest of the process, we bounce back and forth between and : first we find the first value, then use that to find the next value, which lets us find the next value, and so on. For instance, to find the first value, we note that
Then, to find the next value, we use the formula above:
Repeating this process, we can fill in the rest of the table:
Finally, we can estimate that when
Notice that we didn't bother filling in any more in the table than we needed to; we stopped at and we didn't bother filling in the last value.
Use Euler's Method with a step size of to estimate if and