We haven’t yet studied any general ways to solve differential equations. In the first case of exponential growth we found an easy way to solve the equation, but for the logistic equation we just gave the solution and showed that it indeed satisfied the equation. Here we are going to look at some methods for finding not the exact solution, but approximations of the solutions. The first method is the method of Direction Fields and it will give us a good idea of what the solutions are going to look like. The second method, Euler’s method will give us an approximation to a single solution and we will be able to improve it to get arbitrarily good solutions to any differential equation (so long as there aren’t particularly nasty pathologies in the differential equation).

Direction Fields

Let’s take a differential equation:

 

\frac{dy}{dx}=x+y

 

Note that sometimes we will say explicitly that y(x) and sometimes we will leave it implicit, because the equation has a derivative of y with respect to x. You should become familiar with being able to spot which variable is a function of which other by looking at the derivatives.

Remember, what we are looking for is not just a function which solves a differential equation, but all functions which solve them. This means that for any value of x and y in the above equation, we can find a curve which locally has the derivative given by x+y. We can’t yet solve for the whole curve, but we can solve for a tiny piece of it. This is what we will do when we look for a direction field. We’re going to look for little pieces of function which satisfy the differential equation. This might seem like a rather alien concept, but it will prove rather useful.

We know then that given a point x and y we can find the derivative there. Let’s say we pick the point ($3,2$). At this point, a function which solves the differential equation and goes through there will have gradient 3+2=5. We can think about drawing in a tiny bit of the function, let’s say a short line segment there with gradient 5.

We know that close to the point (3,2) the function will still have gradient roughly 5, so drawing in a short straight line (ie. one where the gradient is constant) is going to be a reasonable approximation to whatever the function will really do there. Of course at (3.1,2.1) the gradient will be a little more than 5, and at (2.9,1.9) it will be a little less than 5, but that is the approximation we’re making.

We can go through a whole array of points in the (x,y) plane and work out what the gradients of lines going through them will be. What we will be doing is actually mapping out all of the solutions to the differential equation.

Given an initial condition, of course we won’t go through all points in the plane, but we are now mapping out the flow of all possible initial conditions. Let’s do this for a grid of in the (x,y) plane and work out the derivative of the function at those points:

 

\begin{array}{c|ccccccc}  y\,\,\,\,\,\,x: & -3 & -2 & -1 & 0 & 1 & 2 & 3 \\  \hline  -3 & -6 & -5 & -4 & -3 & -2 & -1 & 0 \\  -2 & -5 & -4 & -3 & -2 & -1 & 0 & 1 \\  -1 & -4 & -3 & -2 & -1 & 0 & 1 & 2 \\  0 & -3 & -2 & -1 & 0 & 1 & 2 & 3 \\  1 & -2 & -1 & 0 & 1 & 2 & 3 & 4 \\  2 & -1 & 0 & 1 & 2 & 3 & 4 & 5 \\  3 & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\  \end{array}

 

We can then draw a plot in the (x,y) plane of small lines, with these gradients, at these points. This will look like this:

dirfield1

Direction fields for the equation \frac{dy}{dx}=x+y for points at integer values of x and y.

If we want to see this in more detail then we can look at a larger number of grid points and we will find, for instance, the direction field in this figure:

dirfield2

You should get a general sense of the “flow” in these diagrams. You can image that a particular function is going to follow along a set of flow lines. In fact, the solution of this equation is known, and is y(x)=-1-x+Ce^x.

Four different solutions with different initial conditions (ie. different values of c) are shown in figure the following figure on top of the direction fields.

dirfield3
You can thus see that given any first order differential equation, you can figure out the direction field by simply plugging in the x and y values. This will give the general behaviour of all solutions of the differential equation.

 

Euler’s method
The method of Direction Fields was a useful way to get the general behaviour of all solutions to a differential equation. Euler’s method is going to allow us to find an approximation of a particular solution given an initial condition. Let’s take the same equation that we had in the previous example:

\frac{dy}{dx}=x+y

 

but now we are going to ask what the solution which has initial condition (0,-0.5) (ie. at x=0, y=-0.5) looks like.

We know that close to this point, the gradient of the graph is going to be -0.5 (ie. 0+(-0.5)), so we can draw a short line at that point with gradient -0.5.

Let’s draw a line of extension 1 in the x direction from the point (0,-0.5) with gradient -0.5. This is going to take us to the point (1,-1) At this point we again look at the differential equation and it tells us that the gradient at that point (1,-1) should be 0 (ie. 1+(-1)), so we draw a line with gradient 0 another unit in the x direction, which takes us to the point (2,-1). Again, we ask what the gradient should be at this point, and clearly it should be 1. We draw in a line of gradient 1 of length 1 which will take us to the point (3,0). We continue this again and again until we have got as far in the x direction as we want.

Of course we chose to go 1 unit in the x direction each time but in fact this is a very crude approximation. We know that really the gradient will be changing continuously but we are letting it change only discretely. We could shorten the lines that we use, say to 0.5 long, or 0.1 long, or 0.01 long and each time it would give us a better and better approximation of the real solution to the differential equation. Various length sections for Euler’s method are shown in the following:

eulerflow

We will do more examples in class and please ask if the general idea here is not clear.

How clear is this post?