Most of the differential equations you've likely encountered in your early studies of calculus have been separable equations. That means it was possible to group terms (say in x and y) on either side of the equation and integrate each side separately. Most differential equations that are of any use in the world aren't separable, and we need other methods to solve them.
There are many such methods, and whole college classes are devoted to them.
In this section, we discuss one method, presented by Swiss mathematician Leonhard Euler (pronounced Oy-ler), for estimating specific solutions that are close to some initial condition (sometimes called a "boundary condition").
Remember that the general solution to a differential equation is a whole set of functions, and the specific solution (which we find by knowing an initial condition–sometimes "boundary condition") is one of those functions.
Let's say (just for the sake of argument right now) that we know the specific solution of a differential equation. Now let's think about how we might estimate some of that function (we might not need it all) that solves our differential equation using the derivative, dy/dx, embedded in the equation.
If we start at the point (x, y), the initial condition, and assuming we can at least solve the differential equation for dy/dx, we can calculate the slope of the function at that point: it's dy/dx – easy. Now let's imagine moving to the right a small distance – we'll call it Δx. That's going to be the x-coordinate of a new point on our estimated solution, and Δy is just Δx multilied by the slope at x. That's where this becomes an estimate, because the slopes of the solution as x and x + Δx are surely different, but if Δx is small, they won't be too different. So if we calculate Δy (from Δx and the slope), and add it to y, we get the new y-coordinate, and we have a new point on our solution curve: (x + Δx, y + Δy). Graphically, the first step looks like this:
If Δx is small enough, the slope we calculate using the differential equation at x will be very close to that at Δx, so our point won't be too far off the curve, but it's unlikely to be exaclty on it.
We can repeat Euler's method to build out our function (actually in either direction) from the initial known point. Of course, the farther we go, the more the small errors could add up, and we might expect our estimate to wander, as the green estimate in the graph below does.
If we can tolerate some error, Euler's method is a good way of estimating the value of a specific solution to a differential equation in the neighborhood of the known point. For example, if we knew the exact value at x = 2, then it would make sense to try to find the value at x = 3 by using, say, 5 steps of Euler's method with a Δx of 0.2. The Δx you use will be a matter of trial and error. The smaller the better, but then it takes longer to get to the solution.
In this example, let's use Euler's method to estimate a specific solution of a separable differential equation, one that we can already integrate directly and find the exact solution. That way we can judge the quality of our approximation.
Our differential equation will be
As usual, we'll begin by separating variables ...
then integrating both sides
If we raise both sides of that result as a power of e, and take advantage of the laws of exponents to turn the additive constant C into the multiplicative constant A, we get the general solution,
Now we'll use the boundary condition y(0) = 2, to find that A = 2, so we have the specific (and exact) solution,
Now we'll solve this equation, starting at (0, 2) with Euler's method, to find an approximation of the solution at x = 1, and compare it to the exact value.
To apply Euler's method, first decide on a step size for Δx. Smaller is better, but there is a diminishing return, and you don't want to take forever. On the other hand, Euler's method is perfect for automating or running in a spreadsheet.
- Decide on a step size, Δx.
- Start with a point (x, y),
- calculate the slope, dy/dx at that point using the differential equation,
- calculate Δy = Δx (dy/dx),
- add Δx to x and Δy to y to form the next point, and
- ... do that until you reach the target x-value.
It's easiest to keep things organized in a table. With a step size of Δx = 0.2, here's the first line of such a table (you can organize your own in your own way), on our way to finding the solution at x = 1. Remember (0.0, 2.0) is a point we already know, our initial condition, and that dy/dx is defined by the differential equation: dy/dx = xy
The next point is just where the first step ended up, at (x + Δx, y + Δy), then we just keep on going, bridging the gap between x = 0 and x = 1 in Δx = 0.2 increments. The next step is
Finally, the whole table looks like this:
Now our estimate of f(1) = 2.919 is about 11% different from the exact value of 3.3. That may or may not be an error we can tolerate.
We might be able to improve on the approximation by choosing a smaller step size, which would keep the jump in slopes from one point to another smaller – remember, the slope used to calculate Δy is the slope from the previous point.
The graph on the right shows how our estimate and the exact value of the solution slowly diverge as we go from x = 0 to x = 2.
In this example, we'll estimate a solution of a non-separable differential equation:
Our initial point will be (2, 1), and we'll use that to try to estimate the solution at x = 3 by building out to the right (+x direction) in various increments. We'll try Δx = 0.1, Δx = 0.05 and Δx = 0.01. I'll show tables for the first two, then let you make a spreadsheet for the last one, which has 100 steps.
For a step size of 0.1, y(3) = 6.37. If we decrease the step size to 0.05, the estimate is 6.61. But the question we really need to ask is whether, as we decrease the step size, the estimate converges. Convergence means that at some point, each time we decrease the step size, the estimate changes by a smaller amount.
The plot shows what happens to the estimate of y(3) as we increase the size of the x-step from 0.1 to 0.001. Notice that the value (moving from lower right to upper left) seems to be changing less each time we add more steps. Smaller steps are generally better if you have the time.
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2012, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to email@example.com.