DEtools
DEplot
plot solutions to a system of DEs
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
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)
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
The optional equations, eqns, consist of the following, as well as a restricted set of plot and dsolve/numeric options.
'animatecurves'
'animatefield'
'animate'
'arrows'
'arrowsize'
'color'
'dirfield'
'dirgrid'
'iterations'
'linecolor'
'number'
'numframes'
'numpoints'
'numsteps'
'obsrange'
'scene'
'stepsize'
animatecurves = true or false (default = false)
animatecurves creates an animation of the evolving solution curve from the specified initial value(s) with respect to time. The default number of animation frames is 25, which can be changed with the numframes option. dsolve/numeric is used to compute the solution curves for all specified initial values at different times. Note that if numpoints is provided, and the number of intervals (numpoints−1) does not divide evenly by the number of frame intervals (numframes−1), then a warning is produced, and numpoints is modified to be numpoints−1numframes−1⁢numframes−1+1.
animatefield = true or false (default = false)
animatefield creates an animation of the direction field with respect to time (that is, the arrows describing the direction field move as a solution with respect to time). The default number of animation frames is 25, which can be changed with the numframes option. dsolve/numeric/rkf45 is used to compute the trajectory of each arrow.
animate = true or false (default = false)
animate is a shortcut that can be used to specify that both animatefield (if applicable) and animatecurves (if applicable) be used.
arrows = arrowtype
arrowtype can be one of 'small', 'smalltwo', 'medium', 'mediumfill', 'large', 'curve', 'comet', 'line', or 'none'
The arrowtype indicates the type of arrow to be used in a direction field. The default, when a direction field is possible, is 'small'. Specifying an arrowtype of 'none' suppresses the calculation and display of any direction fields.
arrowsize = float or magnitude
When arrowsize=magnitude, the size of the arrows is proportional to the magnitude of the direction field. When arrowsize is specified as a positive floating-point value, then this value is used to modify the size of all arrows in the direction field. The default value is arrowsize=1.0.
color, colour = arrowcolor
arrowcolor can take many forms:
any value understood by plot,color;
the literal 'magnitude' or 'magnitude[legacy]';
magnitude[plot,color value, plot,color value];
an expression in two variables;
a procedure in two variables;
a three-element list of expressions in two variables; or
a three-element list of procedures in two variables.
In case 2), the color of the arrows is determined by the magnitude of the field, where a blue shade is used for the lowest magnitude, and a red shade is used for the highest with the exact colors determined from the default plotting palette set by plots:-setcolors using the first color and a contrasting shade computed by ColorTools:-CoolWarmPair. The literal 'magnitude[legacy]' will result in the previous default value of [blue, red]. Case 3) is identical to case 2), but the low and high magnitude colors are specified as the indices of magnitude (for example magnitude["Blue","Red"]). In cases 4) and 5), coordinates of the arrows in the plane are passed to the expression or procedure. The resulting values are then normalized on the range [0,1] and used as 'HUE' values. In cases 6) and 7), the resulting values are normalized on [0,1] and used as RGB values. Note that 4) and 6) must contain expressions of the plotted variables. This form of color handling is useful in differentiating features of the direction field.
The default arrow color is the first color of the default plotting palette as set by plots:-setcolors. The previous default of red can also be specified with color=legacy.
dirfield = [posint,posint], posint, or [[float,float],[float,float],...]
If [posint,posint] is used, it specifies a grid on which to place the arrows. This is identical to the deprecated dirgrid option. If posint is used, it specifies the number of randomly positioned arrows to use for the direction field. If [[float,float],[float,float],...] is used, each sublist describes a point at which an arrow is to be drawn.
dirgrid = [posint, posint]
The dirgrid option is maintained only for backward compatibility. It corresponds to the dirfield = [posint, posint] option.
iterations = posint
iterations provides a method of decreasing the step size while leaving the number of stored points constant. For example, setting stepsize=0.05 and iterations=5 computes internally with a step size of 0.01 but only stores every 5th point. This option is deprecated by numpoints, and is ignored by methods except the classical methods.
linecolor = line_info
line_info can take one of six forms:
an expression of the independent variable;
a procedure of the independent variable;
the keyword legacy.
In cases 2) and 3), values of the independent variable are passed to the expression or procedure. The resulting values are then normalized on [0,1] and applied as 'HUE' values. This color feature is useful in displaying how the solution curve varies with the independent variable.
In addition, forms 1) to 3) can be combined into a list, one element for each of the solution curves considered. Each list element is then applied to a corresponding solution curve.
Option 4) provides the old default line color of yellow.
When no option is provided, Maple's plot color palette is used (see plots:-setcolors) with the first color of the palette used to color the arrows, and lines colored starting with the second color in most cases (for CVD palettes, the first two colors are reserved for the arrows, and the lines are colored starting with the third color).
number = posint
number specifies the number of equations in the procedure-form first order system in dproc (see calling sequences above).
numframes = posint
numframes specifies the number of frames used for animations, using any of the animate, animatefield, or animatecurves options.
numpoints = posint
numpoints specifies the number of points used to plot the curves over the specified time range. The default number of points is 49. Note that for animations, numpoints−1 must be an integer multiple of numframes−1.
numsteps = posint
numsteps allows specification of the stepsize parameter by a more convenient means. For trange=a..b, specifying numsteps=n computes with a step size of b−an. This option is independent of numpoints.
Note: This option only applies to classical fixed step size methods, which are not the default.
obsrange = true or false
obsrange indicates whether the integrator should stop once the solution curve has passed outside the specified range. It also specifies that any arrows that pass completely outside the viewing area should be removed (for an arrow-based animation). This is useful in the plotting of functions with asymptotic behavior. The default is true.
scene = [name, name]
scene specifies the axes of the plot to be viewed. For example, scene=[x, y] indicates that the plot of x versus y (x horizontal) is to be plotted, with t implicit, while scene=[t, y] plots t versus y with t explicit. This option can also be used to change the order in which to plot the variables. There is no default ordering when vars is indicated as a set; if vars is given as a list, the given ordering is used.
size = float, magnitude or [h,w]
Note that use of this option to specify the size of the plotted arrows is deprecated, and will be removed in a future release. To control the size of the plotted arrows use arrowsize instead. The size option is used to control the size of the plot in the interface. See plot/options for more information on the syntax for this functionality.
stepsize = realcons
stepsize specifies the step size used by dsolve when computing the curves in the plot using the classical methods. For trange=a..b, the default value is b−a48.
Note: The solution curves are plotted with a default line thickness of 3, but this can be changed with the thickness plot option.
There are many other optional equations that can be specified, for example, the thickness option. For more information, see plot/options and the individual dsolve/numeric help pages.
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:
x⁡t0=x0,y⁡t0=y0,x⁡t1=x1,y⁡t1=y1,...
y⁡t0=y0,y⁡t1=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.
x⁡t=x1..x2, y⁡t=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].
This first example is for a first order equation. It is for Newton's law of cooling. The differential equation is
with⁡DEtools:
NLC≔diff⁡y⁡t,t=k⁢Am−y⁡t;Am≔20;k≔0.1
NLC≔ⅆⅆty⁡t=k⁢Am−y⁡t
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≔y⁡0=10,y⁡0=30,y⁡0=50
DEplot⁡NLC,y⁡t,t=0..20,ivs
DEplot⁡NLC,y⁡t,t=0..40,y=0..60,ivs,arrows=medium,linecolor=black
The second example is a first order system in x⁡t and y⁡t. It is the SIR virus model where x is the susceptible population and y is the infected population. The differential equations are:
deS≔diff⁡x⁡t,t=−0.5⁢x⁡t⁢y⁡t
deS≔ⅆⅆtx⁡t=−0.5⁢x⁡t⁢y⁡t
deI≔diff⁡y⁡t,t=0.5⁢x⁡t⁢y⁡t−0.15⁢y⁡t
deI≔ⅆⅆty⁡t=0.5⁢x⁡t⁢y⁡t−0.15⁢y⁡t
The first plot shows one initial value x⁡0=0.98 and y⁡0=0.01 meaning 1% of the population is infected at time t=0.
DEplot⁡deS,deI,x⁡t,y⁡t,t=0..40,x=0..1,y=0..0.6,x⁡0=0.99,y⁡0=0.01,arrows=medium
This second plot animates the solution curve in time.
Note: To play an animation in this help page, right-click (Control-click, on Mac) the plot to display the context menu. Select Animation > Play.
DEplot⁡deS,deI,x⁡t,y⁡t,t=0..40,x=0..1,y=0..0.6,x⁡0=0.99,y⁡0=0.01,arrows=medium,animatecurves=true
This third example is a second order differential equation. It is a damped harmonic oscillator m⁢x''=−c⁢x'−k⁢x 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≔diff⁡x⁡t,t,t=−x⁡t−12⁢diff⁡x⁡t,t
de≔ⅆ2ⅆt2x⁡t=−x⁡t−ⅆⅆtx⁡t2
DEplot⁡de,x⁡t,t=0..15,x=−1..1,x⁡0=1,D⁡x⁡0=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 versus x. In the second plot, we use the scene option to obtain a plot of x versus t. In the third plot, we show some options for improving the quality of the solution curve.
sys≔diff⁡x⁡t,t=y⁡t,diff⁡y⁡t,t=−x⁡t−12⁢y⁡t
sys≔ⅆⅆtx⁡t=y⁡t,ⅆⅆty⁡t=−x⁡t−y⁡t2
DEplot⁡sys,x⁡t,y⁡t,t=0..15,x⁡0=1,y⁡0=0
DEplot⁡sys,x⁡t,y⁡t,t=0..15,x⁡0=1,y⁡0=0,scene=t,x⁡t
DEplot⁡sys,x⁡t,y⁡t,t=0..15,x⁡0=1,y⁡0=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;
F1 ≔ procN,x,Y,YPYP[1] ≔ Y[2];YP[2] ≔ −Y[1] − 1/2*Y[2]end proc
DEplot⁡F1,x⁡t,y⁡t,t=0..15,number=2,y⁡0=1,y⁡0=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≔diff⁡x⁡t,t=x⁡t⁢1−y⁡t,diff⁡y⁡t,t=0.3⁢y⁡t⁢x⁡t−1
LVS≔ⅆⅆtx⁡t=x⁡t⁢1−y⁡t,ⅆⅆty⁡t=0.3⁢y⁡t⁢x⁡t−1
DEplot⁡LVS,x⁡t,y⁡t,t=0..10,x=−1..2,y=−1..2,arrows=large,title=`Lotka-Volterra model`,color=magnitude
DEplot⁡LVS,x⁡t,y⁡t,t=0..10,x=0..3,y=0..2,arrows=comet,x⁡0=1,y⁡0=0.5,title=`Lotka-Volterra model`,dirfield=500
DEplot⁡LVS,x⁡t,y⁡t,t=0..12,x=0..3,y=0..2,arrows=comet,x⁡0=1,y⁡0=0.5,animatecurves=true,dirfield=300
DEplot⁡LVS,x⁡t,y⁡t,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 z⁡t versus y⁡t. To see a plot of x⁡t verses y⁡t verses z⁡t in 3 dimensions, use DEtools[DEplot3d].
sys≔D⁡x⁡t=y⁡t−z⁡t,D⁡y⁡t=z⁡t−x⁡t,D⁡z⁡t=x⁡t−y⁡t⋅2
sys≔D⁡x⁡t=y⁡t−z⁡t,D⁡y⁡t=z⁡t−x⁡t,D⁡z⁡t=x⁡t−2⁢y⁡t
DEplot⁡sys,x⁡t,y⁡t,z⁡t,t=−2..2,x⁡0=1,y⁡0=0,z⁡0=2,scene=z⁡t,x⁡t,method=classicalforeuler,stepsize=0.05
The seventh example, a 3rd order equation, illustrates how to input higher order derivatives and initial values.
de≔cos⁡x⁢diff⁡y⁡x,`$`⁡x,3−diff⁡y⁡x,`$`⁡x,2+π⁢diff⁡y⁡x,x=y⁡x−x
de≔cos⁡x⁢ⅆ3ⅆx3y⁡x−ⅆ2ⅆx2y⁡x+π⁢ⅆⅆxy⁡x=y⁡x−x
DEplot⁡de,y⁡x,x=−2.5..1.4,y⁡0=1,D⁡y⁡0=2,D2⁡y⁡0=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↦x⋅1−y−0.1⋅x:g≔x,y↦0.3⋅y⋅x−1:
MLV≔diff⁡x⁡t,t=f⁡x⁡t,y⁡t,diff⁡y⁡t,t=g⁡x⁡t,y⁡t
MLV≔ⅆⅆtx⁡t=x⁡t⁢1−y⁡t−0.1⁢x⁡t,ⅆⅆty⁡t=0.3⁢y⁡t⁢x⁡t−1
solve⁡f⁡x,y=0,g⁡x,y=0,x,y
x=0.,y=0.,x=10.,y=0.,x=1.,y=0.9000000000
ivs≔x⁡0=1,y⁡0=0.5,x⁡0=1,y⁡0=1.5
DEplot⁡MLV,x⁡t,y⁡t,t=0..10,ivs,arrows=smalltwo,dirfield=12,12,color=magnitudegreen,red
DEplot⁡MLV,x⁡t,y⁡t,t=−8..8,ivs,arrows=mediumfill,color=f⁡x⁡t,y⁡t,g⁡x⁡t,y⁡t,0.5,linecolor=t2
DEplot⁡MLV,x⁡t,y⁡t,t=0..10,ivs,arrows=comet,dirfield=200,color=magnitude,linecolor=black
DEplot⁡MLV,x⁡t,y⁡t,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⁡diff⁡y⁡x,x=12⁢−x−x2+4⁢y⁡x12,y⁡x,x=−3..3,y=−3..2,title=`Restricted domain`,color=12⁢−x−x2+4⁢y
The final examples illustrate other aspects of differential equations using animation. To play the animation, right-click (Control-click for Mac) the plot and then select Animation > Play.
vdP≔diff⁡x⁡t,t=10⁢y⁡t−x⁡t33+x⁡t,diff⁡y⁡t,t=−110⁢x⁡t
vdP≔ⅆⅆtx⁡t=10⁢y⁡t−10⁢x⁡t33+10⁢x⁡t,ⅆⅆty⁡t=−x⁡t10
DEplot⁡vdP,x⁡t,y⁡t,t=0..20,x=−3..3,y=−2..2,x⁡0=0.2,y⁡0=0.2,title=`van der Pol oscillator`,dirfield=400,arrows=comet,size=magnitude,numpoints=505,linecolor=blue,animatecurves=true
DEplot⁡vdP,x⁡t,y⁡t,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⁡diff⁡x⁡t,t=y⁡t,diff⁡y⁡t,t=−sin⁡x⁡t,x⁡t,y⁡t,t=0..10,x⁡0=0,y⁡0=0.5,x⁡0=0,y⁡0=1,x⁡0=0,y⁡0=1.8,x⁡0=−2⁢π,y⁡0=1,x⁡0=2⁢π,y⁡0=0.5,x⁡0=−2⁢π,y⁡0=2.1,x⁡0=2⁢π,y⁡0=−2.1,title=`Pendulum Vibrations`,dirfield=300,arrows=comet,color=magnitude,linecolor=blue,animate=true
r≔0.7⁢sqrt⁡x⁡t2+y⁡t2:
des≔diff⁡x⁡t,t=sin⁡r⁢x⁡t−y⁡t,diff⁡y⁡t,t=sin⁡r⁢y⁡t+x⁡t
des≔ⅆⅆtx⁡t=sin⁡0.7⁢x⁡t2+y⁡t2⁢x⁡t−y⁡t,ⅆⅆty⁡t=sin⁡0.7⁢x⁡t2+y⁡t2⁢y⁡t+x⁡t
DEplot⁡des,x⁡t,y⁡t,t=0..2,x=−15..15,y=−15..15,color=magnitude,title=`Stable Limit Cycles`,arrows=curve,dirfield=800,axes=none
DEplot⁡des,x⁡t,y⁡t,t=0..2,x=−15..15,y=−15..15,title=`Stable Limit Cycles`,arrows=comet,dirfield=300,animate=true
The DEtools[DEplot] command was updated in Maple 2023.
The color and linecolor options were updated in Maple 2023.
See Also
DEplot3d
DEplot[interactive]
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:-setcolors
plots[odeplot]
Download Help Document