DEtools (DEplot)

Maple's
DEtools library contains several commands that are useful for plotting solutions of differential equations. We will use one of them to plot direction fields (see section 6.12 of Thomas (9th and alternate editions) for an explanation of direction fields) of first-order differential equations together with solution curves. The command is called DEplot. Since it is in a library, to use it, we must first load it into memory by typing:

>   with(DEtools,DEplot);

[DEplot]

The syntax of DEplot is complicated !!   The reason for this is that there is a lot of information you must supply to the program about the differential equation to be solved, initial conditions if solution curves are desired, and how to plot. The trick is to put it in the right order.

Example: Suppose we want to produce the direction field and some representative solution curves for the equation  y'+x*y=1.  And for some reason, we're interested in solutions defined near x=0, and y=0.  We decide to have our plot window be for x from -2..2 and y from -2..2.  We'll plot the direction field and some solution curves. Since the solutions are specified by their initial conditions, we plot the solutions corresponding to the conditions y(0)=-1, y(0)=-0.5, y(0)=0, y(0)=0.5 and y(0)=1. Here is the statement that does it all:

>   DEplot(diff(y(x),x)=1-x*y(x),y(x),x=-2..2,{[0,-1],[0,-0.5],[0,0], [0,0.5],[0,1]}, y=-2..2,linecolor=black,color=black);

[Maple Plot]

The pieces of the syntax are:

DEplot( ...); -- the name of the command (obviously)

diff(y(x),x)=1-x*y(x)-- the differential equation. Note that the format of the differential equation is similar to that for dsolve. One difference, however, is that the diff(y(x),x) part of the differential equation must appear by itself on the left of the = sign -- that's why we subtracted the x*y(x) over to the right (otherwise the direction field is not plotted correctly).

y(x) -- tells the name of the dependent variable

x=-2..2 -- gives the range of values to be plotted on the x axis -- also the range of x values for which the solutions are to be computed.

{[0,-1],[0,-0.5],......} -- gives the initial conditions -- y(0)=-1 translates into going through the point [0,-1], etc.. Having too many of these can clutter the plot and can also take a long time.

y=-2..2 -- gives the range of y to plot on the vertical axes (the solution curves are allowed to run off the plot).

That's basically it. There are only two minor variations:

1. If all you want is the direction field, without any sample solution curves, the initial conditions argument of
DEplot may be omitted, as follows:

>   DEplot(diff(y(x),x)=1-x*y(x),y(x),x=-2..2,y=-2..2,color=black);

[Maple Plot]


2. Maple uses a numerical procedure (like the trapezoidal rule for integrals) to find the solution curves. If they look too "clunky" you can improve them by decreasing the "
stepsize" parameter (it increases the accuracy and causes Maple to plot more points, just as for the trapezoidal rule for integration). But decreasing it too much can make the plot take a LONG time to produce. Here is an example:

>   DEplot(diff(y(x),x)=x*y(x)^2,y(x),x=-1..1,{[0,0.5],[0,-0.5]},y=-1..1,stepsize=0.05,color=black,linecolor=black);

[Maple Plot]

Additional information on the DEplot command (in particular, its use for systems of equations) may be obtained from its Help screen.