plot solutions to a system of DEs - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : Packages : DEtools : DEtools/DEplot

This page is an exact match for your search term. Click here to search for all help pages containing the term, "deplot"

DEtools[DEplot] - plot solutions to a system of DEs

Calling Sequence

DEplot(deqns, vars, trange, options)

DEplot(deqns, vars, trange, inits, options)

DEplot(deqns, vars, trange, xrange, yrange, options)

DEplot(deqns, vars, trange, inits, xrange, yrange, options)

DEplot(dproc, vars, trange, number, xrange, yrange, options)

Parameters

deqns

-

list or set of first order ordinary differential equations, or a single differential equation of any order

dproc

-

a Maple procedure representation for first order ordinary differential equations, or a single differential equation of any order

vars

-

dependent variable, or list or set of dependent variables

trange

-

range of the independent variable

number

-

equation of the form 'number'=integer indicating the number of differential equations when deqns is given as a function (dproc) instead of expressions

inits

-

set or list of lists; initial conditions for solution curves

xrange

-

range of the first dependent variable

yrange

-

range of the second dependent variable

options

-

(optional) equations of the form keyword=value

Description

• 

Given a set or list of initial conditions (see below), and a system of first order differential equations or a single higher order differential equation, DEplot plots solution curves, by numerical methods.

  

Note: This means that the initial conditions of the problem must be given in standard form, that is, the function values and all derivatives up to one less than the differential order of the differential equation at the same point.

• 

A system of two first order differential equations produces a direction field plot, provided the system is determined to be autonomous. In addition, a single first order differential equation produces a direction field (as it can always be mapped to a system of two first order autonomous differential equations). A system is determined to be autonomous when all terms and factors, other than the differential, are free of the independent variable. For more information, see DEtools[autonomous]. For systems not meeting these criteria, no direction field is produced (only solution curves are possible in such instances). There can be only one independent variable.

• 

The default method of integration is method=rkf45. Other methods can be specified in the optional equations. Note that because numerical methods are used to generate plots, the output is subject to the characteristics of the numerical method in use. In particular, unusual output may occur when dealing with asymptotes.

• 

The direction field presented consists of either a grid of arrows or a set of randomly generated arrows. In either case, the arrows are tangential to solution curves. For each grid point, the arrow centered at x,y has slope dydx. This slope is computed using dydt/dxdt, where these two derivatives are specified in the first argument to DEplot. The curved arrow types (curves and comet) require additional data for the curvature of the direction field, which is computed by moving an epsilon in the direction of the slope dydx, and computing dydx, then moving an epsilon in the direction opposite the slope, and computing dydx. This data is then sufficient to draw a small portion of the direction field lines local to the point, which is then used to draw the curved arrows.

• 

By default, the two dependent variables are plotted, unless otherwise specified in the scene option.

• 

The deqns parameter can be given as a procedure, but must conform to the specification as given in dsolve/numeric, and the number option must be included before the initial conditions. In this instance, deqns must be of the form:

proc( N, ivar, Y, YP )

    ...

    YP[1] := f1(ivar,Y);

    YP[2] := f2(ivar,Y);

    ...

end proc

  

where N represents the number of first order equations, ivar is the independent variable, Y is a vector of length N, and YP is a vector of derivatives which is updated by the procedure (for the equivalent first order system), also of length N. For information on determining first order systems, see DEtools[convertsys]. N is given in this case by the fourth parameter number.

• 

The inits parameter must be specified as:

xt0=x0,yt0=y0,xt1=x1,yt1=y1,...

yt0=y0,yt1=y1,...

yt0=y0,yt1=y1,...

  

where, in the above, sets can be used in place of lists, or

t0,x0,y0,t1,x1,y1,...

{ t0,x0,y0,t1,x1,y1,... }

t0,x0,t1,x1,...

  

where the above is a list or set of lists, each sublist specifying one group of initial conditions.

• 

The xrange and yrange parameters must be specified as follows.

xt=x1..x2, yt=y1..y2 or

 x=x1..x2,    y=y1..y2

  

By default, integration along a solution curve stops one mesh point after the specified range is exceeded. This may be overridden by the obsrange option.

• 

More examples can be found in the deplot example worksheet.

• 

DEplot can also be accessed through the interactive DEplot assistant. For more information, see DEplot[interactive].

Examples

This first example is for a first order equation. It is for Newton's law of cooling.  The differential equation is

withDEtools:

NLC:=ⅆⅆtyt=kAmyt;Am:=20;k:=0.1

where y is the temperature at time t and we have set the Ambient temperature Am to 20 degrees and the cooling rate constant k to 0.1. We plot the solution for initial temperatures 10, 30, and 50 degrees. In the second plot we change the ranges for time t and temperature y.

ivs:=y0=10,y0=30,y0=50

DEplotNLC,yt,t=0..20,ivs

DEplotNLC,yt,t=0..40,y=0..60,ivs,arrows=medium,linecolor=black

The second example is a first order system in xt and yt. It is the SIR virus model where x is the susceptible population and y is the infected population.  The differential equations are:

deS:=ⅆⅆtxt=0.5xtyt

deI:=ⅆⅆtyt=0.5xtyt0.15yt

The first plot shows one initial value x0=0.98 and y0=0.01 meaning 1% of the population is infected at time t=0.

DEplotdeS,deI,xt,yt,t=0..40,x=0..1,y=0..0.6,x0=0.99,y0=0.01,arrows=medium

This second plot animates the solution curve in time. To run the animation, click on the plot then press the play button.

DEplotdeS,deI,xt,yt,t=0..40,x=0..1,y=0..0.6,x0=0.99,y0=0.01,arrows=medium,animatecurves=true

This third example is a second order differential equation. It is a damped harmonic oscillator mx''=cx'kx where x is the position of the object at time t, m=2 is its mass, k=2 is the spring constant and c=1 is the damping constant.

de:=ⅆ2ⅆt2xt=xt1ⅆⅆtxt2

DEplotde,xt,t=0..15,x=1..1,x0=1,Dx0=0

The fourth example shows the same damped Harmonic oscillator above but input as a system of two first order equations.  Here yt=x't is the velocity.  By default the plot is a plot of y verses x. In the second plot, we use the scene option to obtain a plot of x verses t. In the third plot, we show some options for improving the quality of the solution curve.

sys:=ⅆⅆtxt=yt,ⅆⅆtyt=xt1yt2

DEplotsys,xt,yt,t=0..15,x0=1,y0=0

DEplotsys,xt,yt,t=0..15,x0=1,y0=0,scene=t,xt

DEplotsys,xt,yt,t=0..15,x0=1,y0=0,x=1..1,y=1..1,numpoints=200,linecolor=black,axes=boxed

Here is the same plot as above, but using the procedure input form.

F1 := proc(N,x,Y,YP)                  # First order system
    YP[1] := Y[2];
    YP[2] := -Y[1]-1/2*Y[2];
end proc;

DEplotF1,xt,yt,t=0..15,number=2,y0=1,y0=0,x=1..1,y=1..1,numpoints=200,linecolor=black,axes=boxed

The fifth set of examples are plots of the Lotka-Volterra predator-prey system. Here x is the prey population and y is the predator population. The first plot shows a plot of the direction field where color is used to indicate the velocity. The second plot shows the direction field with 300 randomly placed "comets." In the third plot we animate the direction field and in the fourth plot we animate the solution curves. Note, the second animation may take a minute or two to compute.

LVS:=ⅆⅆtxt=xt1yt,ⅆⅆtyt=0.3ytxt1

DEplotLVS,xt,yt,t=0..10,x=1..2,y=1..2,arrows=large,title=`Lotka-Volterra model`,color=magnitude

DEplotLVS,xt,yt,t=0..10,x=0..3,y=0..2,arrows=comet,x0=1,y0=0.5,title=`Lotka-Volterra model`,dirfield=500

DEplotLVS,xt,yt,t=0..12,x=0..3,y=0..2,arrows=comet,x0=1,y0=0.5,animatecurves=true,dirfield=300

DEplotLVS,xt,yt,t=0..12,x=0..3,y=0..2,arrows=comet,animatefield=true,numframes=50,dirfield=300

The sixth example is a system of three DEs in x't,y't,z't showing how to plot a solution for zt versus yt. To see a plot of xt verses yt verses zt in 3 dimensions, use DEtools[DEplot3d].

sys:=Dxt=ytzt,Dyt=ztxt,Dzt=xtyt2

DEplotsys,xt,yt,zt,t=2..2,x0=1,y0=0,z0=2,scene=zt,xt,method=classicalforeuler,stepsize=0.05

The seventh example, a 3rd order equation, illustrates how to input higher order derivatives and initial values.

de:=cosxⅆ3ⅆx3yxⅆ2ⅆx2yx+πⅆⅆxyx=yxx

DEplotde,yx,x=2.5..1.4,y0=1,Dy0=2,D2y0=1,y=4..5

The next examples illustrate other arrow and color options and also an alternative way for inputting a system from which one can directly solve for the fixed points of the system. This system is a modified Lotka-Volterra system, and these are the commands to create the plot from the Plotting Guide.

f:=x,y→x1y0.1x:g:=x,y→0.3yx1:

MLV:=ⅆⅆtxt=fxt,yt,ⅆⅆtyt=gxt,yt

solvefx,y=0,gx,y=0,x,y

ivs:=x0=1,y0=0.5,x0=1,y0=1.5

DEplotMLV,xt,yt,t=0..10,ivs,arrows=smalltwo,dirfield=12,12,color=magnitudegreen,red

DEplotMLV,xt,yt,t=8..8,ivs,arrows=mediumfill,color=fxt,yt,gxt,yt,0.5,linecolor=t2

DEplotMLV,xt,yt,t=0..10,ivs,arrows=comet,dirfield=200,color=magnitude,linecolor=black

DEplotMLV,xt,yt,t=0..10,ivs,arrows=comet,dirfield=200,size=magnitude,linecolor=cyan,yellow,thickness=5

The next example shows that arrows are plotted only in regions where the direction field is real valued.

DEplotⅆⅆxyx=1xx2+4yx122,yx,x=3..3,y=3..2,title=`Restricted domain`,color=1xx2+4y2

The final examples illustrate other aspects of differential equations using animation.  To play the animations, you must click on the plot then click on the play button.

vdP:=ⅆⅆtxt=10ytxt33+xt,ⅆⅆtyt=1xt10

DEplotvdP,xt,yt,t=0..20,x=3..3,y=2..2,x0=0.2,y0=0.2,title=`van der Pol oscillator`,dirfield=400,arrows=comet,size=magnitude,numpoints=505,linecolor=blue,animatecurves=true

DEplotvdP,xt,yt,t=0..20,x=2..2,y=1..1,title=`van der Pol oscillator`,dirfield=0.2,0.2,0.2,0.2,arrows=comet,color=blue,animatefield=true,numframes=100

DEplotⅆⅆtxt=yt,ⅆⅆtyt=sinxt,xt,yt,t=0..10,x0=0,y0=0.5,x0=0,y0=1,x0=0,y0=1.8,x0=2π,y0=1,x0=2π,y0=0.5,x0=2π,y0=2.1,x0=2π,y0=2.1,title=`Pendulum Vibrations`,dirfield=300,arrows=comet,color=magnitude,linecolor=blue,animate=true

r:=0.7xt2+yt2:

des:=ⅆⅆtxt=sinrxtyt,ⅆⅆtyt=sinryt+xt

DEplotdes,xt,yt,t=0..2,x=15..15,y=15..15,color=magnitude,title=`Stable Limit Cycles`,arrows=curve,dirfield=800,axes=none

DEplotdes,xt,yt,t=0..2,x=15..15,y=15..15,title=`Stable Limit Cycles`,arrows=comet,dirfield=300,animate=true

See Also

DEplot3d, DEplot[interactive], DEtools, DEtools[autonomous], DEtools[phaseportrait], dfieldplot, dsolve/classical, dsolve/dverk78, dsolve/gear, dsolve/lsode, dsolve/numeric, dsolve/rkf45, dsolve/rosenbrock, PDEtools[PDEplot], plot, plot/options, plots[odeplot]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam