 odeplot - Maple Help

Home : Support : Online Help : Graphics : 2-D : odeplot

plots

 odeplot
 2-D or 3-D plot of output from dsolve Calling Sequence odeplot(dsn, vars, range, options) Parameters

 dsn - output from a call to dsolve( ... , numeric) vars - (optional list) axes and functions to plot range - (optional) range; range of the independent variable options - (optional) equations that specify plot options; see plot/options and plot3d/option Description

 • The odeplot function plots or animates one or more solution curves (either 2-D or 3-D) obtained from the output (dsn) of a call to dsolve/numeric.
 Note: If you are using the output=piecewise option with dsolve/numeric, you should use the plot function to plot or animate your solution.
 • The ordering of the coordinates is given by vars. If no coordinates are given, then it is assumed that a plot of the first dependent variable as a function of the independent variable is desired (that is, the first two coordinates of the solution).
 Significantly more flexibility is available in the specification of the coordinates.
 The coordinates can be functions of the independent variable, or any dependent variable and derivative values that are part of the dsolve/numeric solution. For example, for a second-order problem in $y\left(x\right)$, you could specify a plot of $y\left(x\right)$ versus ${y\left(x\right)}^{2}+{\left(\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}y\left(x\right)\right)}^{2}$ with $\left[y\left(x\right),{y\left(x\right)}^{2}+{\left(\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}y\left(x\right)\right)}^{2}\right]$.
 Multiple curves can be plotted by specifying a nested list format. For example, $\left[\left[x,y\left(x\right)\right],\left[x,\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}y\left(x\right)\right]\right]$ displays the dependent variable and its derivative as a function of $x$ on the same plot.
 Curve-specific options can be specified for each curve (for plots with multiple curves) by including them in the desired variable list after the plot variables. Allowed options are color, linestyle, style, symbol, symbolsize, and thickness. (These are described in plot/options and plot3d/option.) For example, the plot described by the nested list above can be displayed with $y\left(x\right)$ in blue dots, and $\frac{ⅆ}{ⅆx}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}y\left(x\right)$ as a red line of thickness 2 with the argument [[x,y(x),color=blue,style=point],[x,diff(y(x),x),color=red,thickness=2]].
 • The range argument defines the range of the independent variable to produce the plot, and must evaluate to real numbers. If not supplied, the range is determined as follows:
 – If the dsolve/numeric output is not of a procedure type (that is, it is in the form of a matrix or Matrix), then the values present in the matrix are used directly for the plot.
 – If the problem is a boundary value problem (BVP), then the plot is produced for the entire solution region.
 – If the problem is a initial value problem (IVP), and was created with a range (rkf45 and rosenbrock only), then that range is used for the plot.
 – If the problem is a IVP, _Env_smart_dsolve_numeric is set to true, and a prior call was made to the procedure, the plot is produced from the initial point to the point used in the prior call.
 – Finally, if none of the above conditions are met, then the plot is produced for the range x0-10..x0+10, where x0 is the initial point for the IVP.
 • If the default numerical IVP solvers rkf45 and rosenbrock were used with the range argument to obtain dsn, then an additional option is available to control the number of points used to produce the plot. The refine=v option tells odeplot to use v times the number of stored points for the plot, where v must be a non-negative integer or one over a non-negative integer.
 For example, specification of refine=1 tells odeplot to use all points in the stored solution, while refine=2 requests twice the computed points, and refine=1/3 requests one-third the computed points.
 Note: Use of this option with a range solution of dsolve/numeric produces an adaptive plot, where more points are plotted in more rapidly changing solution regions (that is, regions where a greater number of steps were required by the numerical method). See the Van der Pol example below.
 Note: This option cannot be used with the numpoints option.
 • If not specified, the labels of the plot are obtained from the vars argument (or from the dsolve/numeric solution if vars is not specified). Since these are displayed as text, the derivative of $y\left(x\right)$ with respect to $x$ is displayed as $y'$, and the function $y\left(x\right)$ is displayed as $y$. Variables specified in vars using operator notation, such as $\mathrm{D}\left(y\right)\left(x\right)$ are left unchanged.
 For 2-D plots, if the length of the text of an automatically-generated axis label exceeds 10 characters, it is not displayed. To display long labels as a legend (instead of omitting them), specify the labels=legend option.
 Labels can be disabled by specifying them as empty strings or identifiers (that is, labels=["",""] or labels=[,]).
 • If the frames=n option is given, then odeplot produces an animation of the solution over the independent variable range for the plot, from lowest to highest value. The final frame of the animation is the same as the plot created without the frames option. Note: The refine option cannot be used with animations, as odeplot must choose the points for the animated plot.
 • Remaining arguments must be equations of the form option = value. These options are the same as found for plot (in the case of 2-D solution curves) or those found for plot3d (in the case of 3-D solution curves). See plot/options and plot3d/option for details.
 • The result of a call to odeplot is a PLOT or PLOT3D data structure which can be rendered by the plotting device. You can assign this value to a variable, save it in a file, then read it back in for redisplay. See plot/structure for more details. Examples

 > $\mathrm{with}\left(\mathrm{plots}\right):$

dsolve/numeric solution using a range, so odeplot defaults to that range

 > $p≔\mathrm{dsolve}\left(\left\{y\left(0\right)=1,\mathrm{D}\left(y\right)\left(x\right)=y\left(x\right)\right\},\mathrm{type}=\mathrm{numeric},\mathrm{range}=-5..2\right):$
 > $\mathrm{odeplot}\left(p\right)$ or with refinement

 > $\mathrm{odeplot}\left(p,\mathrm{refine}=2\right)$ dsolve/numeric matrix output

 > $p≔\mathrm{dsolve}\left(\left\{y\left(0\right)=1,\mathrm{D}\left(y\right)\left(x\right)=y\left(x\right)\right\},\mathrm{numeric},\mathrm{output}=\mathrm{Array}\left(\left[-1,-0.8,-0.6,-0.4,-0.2,0\right]\right)\right):$
 > $\mathrm{odeplot}\left(p\right)$ Animation of a solution

Note: To play an animation in this help page, right-click (Control-click, on Macintosh) the plot to display the context menu.  Select Animation > Play.

 > $p≔\mathrm{dsolve}\left(\left\{y\left(0\right)=1,\mathrm{D}\left(y\right)\left(x\right)=y\left(x\right)\right\},y\left(x\right),\mathrm{type}=\mathrm{numeric}\right):$
 > $\mathrm{odeplot}\left(p,\left[x,y\left(x\right)\right],-1..1,\mathrm{frames}=20\right)$ Removing labels

 > $p≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)=\mathrm{sin}\left(xy\left(x\right)\right),y\left(0\right)=2\right\},y\left(x\right),\mathrm{type}=\mathrm{numeric}\right):$
 > $\mathrm{odeplot}\left(p,\left[x,y\left(x\right)\right],0..6,\mathrm{labels}=\left["",""\right]\right)$ > $\mathrm{sys}≔\mathrm{diff}\left(y\left(x\right),x\right)=z\left(x\right),\mathrm{diff}\left(z\left(x\right),x\right)=y\left(x\right):$
 > $\mathrm{fcns}≔\left\{y\left(x\right),z\left(x\right)\right\}:$
 > $p≔\mathrm{dsolve}\left(\left\{\mathrm{sys},y\left(0\right)=0,z\left(0\right)=1\right\},\mathrm{fcns},\mathrm{type}=\mathrm{numeric},\mathrm{method}=\mathrm{classical}\right):$

Specification of numpoints

 > $\mathrm{odeplot}\left(p,\left[x,y\left(x\right)\right],-4..4,\mathrm{numpoints}=25\right)$ Multiple curves $y\left(x\right)$ and $z\left(x\right)$ against $x$.  This is the command to create the plot from the Plotting Guide.

 > $\mathrm{odeplot}\left(p,\left[\left[x,y\left(x\right)\right],\left[x,z\left(x\right)\right]\right],-4..4\right)$ Phase plot of $y\left(x\right)$ against $z\left(x\right)$

 > $\mathrm{odeplot}\left(p,\left[y\left(x\right),z\left(x\right)\right],-4..4\right)$ Limit the view of the phase plot

 > $\mathrm{odeplot}\left(p,\left[y\left(x\right),z\left(x\right)\right],-4..4,\mathrm{view}=\left[-3..3,0..3\right]\right)$ Three-dimensional solution curve

 > $\mathrm{odeplot}\left(p,\left[x,y\left(x\right),z\left(x\right)\right],-4..4,\mathrm{color}=\mathrm{orange}\right)$ The command to create the 3-D plot from the Plotting Guide is

 > $\mathrm{odeplot}\left(p,\left[\left[x,y\left(x\right),z\left(x\right),\mathrm{color}=\mathrm{orange},\mathrm{style}=\mathrm{point}\right],\left[x,z\left(x\right),y\left(x\right),\mathrm{color}=\mathrm{blue},\mathrm{thickness}=2\right]\right],-5..5\right)$ Multiple curves with different options

 > $\mathrm{odeplot}\left(p,\left[\left[x,y\left(x\right),\mathrm{color}=\mathrm{orange},\mathrm{style}=\mathrm{point}\right],\left[x,z\left(x\right),\mathrm{color}=\mathrm{blue},\mathrm{thickness}=2\right]\right],-4..4\right)$ Same as above, but animated.

Once again, note that to play an animation in this help page, right-click (Control-click, on Macintosh) the plot to display the context menu.  Select Animation > Play.

 > $\mathrm{odeplot}\left(p,\left[\left[x,y\left(x\right),\mathrm{color}=\mathrm{orange},\mathrm{style}=\mathrm{point}\right],\left[x,z\left(x\right),\mathrm{color}=\mathrm{blue},\mathrm{thickness}=2\right]\right],-4..4,\mathrm{frames}=20\right)$ An example (the Van der Pol equation) where use of a solution with range and plotting with option refine gives a significantly higher quality plot than without:

 > $\mathrm{ode}≔\mathrm{diff}\left(x\left(t\right),t,t\right)+1000\left({x\left(t\right)}^{2}-1\right)\mathrm{diff}\left(x\left(t\right),t\right)+x\left(t\right)=0:$
 > $\mathrm{ics}≔x\left(0\right)=2,\mathrm{D}\left(x\right)\left(0\right)=0:$
 > $\mathrm{sol}≔\mathrm{dsolve}\left(\left\{\mathrm{ics},\mathrm{ode}\right\},x\left(t\right),\mathrm{numeric},\mathrm{stiff}=\mathrm{true},\mathrm{range}=0..3000\right):$
 > $\mathrm{odeplot}\left(\mathrm{sol},\left[x\left(t\right),\mathrm{diff}\left(x\left(t\right),t\right)\right],0..3000,\mathrm{refine}=1\right)$ 