Parametrized Problems - Maple Help

Interactive features of numeric ODE/DAE solutions

Description

 Procedure form outputs for initial value dsolve/numeric solutions (ODE and DAE) have several interactive features. This page describes these features, and demonstrates how to use them.

Examples

Initial values

 The initial values used in obtaining the current solution can be queried by calling the dsolve/numeric output procedure with option 'initial' as follows:
 > $\mathrm{dsn}≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)-y\left(x\right)=0,y\left(0\right)=1\right\},\mathrm{numeric}\right)$
 ${\mathrm{dsn}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $\mathrm{dsn}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({x}\right){=}{2.71828133411964}\right]$ (2)
 > $\mathrm{dsn}\left('\mathrm{initial}'\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{1.}\right]$ (3)
 > $\mathrm{dsn2}≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)-y\left(x\right)=0,y\left(0\right)=1\right\},\mathrm{numeric},\mathrm{output}=\mathrm{operator}\right)$
 ${\mathrm{dsn2}}{≔}\left[{x}{=}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}{,}{y}{=}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}\right]$ (4)
 > $\mathrm{dsn2}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({1}\right){=}{2.71828133411964}\right]$ (5)
 > $\mathrm{dsn2}\left('\mathrm{initial}'\right)$
 $\left[{x}{}\left({\mathrm{initial}}\right){=}{0.}{,}{y}{}\left({\mathrm{initial}}\right){=}{1.}\right]$ (6)
 In addition, initial values can be changed by calling the solution procedure with an equation of the form $\mathrm{initial}=\mathrm{newvalues}$, where newvalues is a list of new numeric initial values in the same order as specified for the solution output (i.e. if calling the solution procedure returns the values for $x,y$ in a list, initial must be specified as $\left[\mathrm{x0},y\left(\mathrm{x0}\right)\right]$).
 > $\mathrm{dsn}\left(\mathrm{initial}=\left[0,2\right]\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{2.}\right]$ (7)
 > $\mathrm{dsn}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({x}\right){=}{5.43656271691257}\right]$ (8)
 For listprocedure and operator output form, the list can be provided to any of the procedures, or individual values can be changed by providing a single value instead of a list:
 > $\mathrm{op}\left(\left[1,2\right],\mathrm{dsn2}\right)\left(\mathrm{initial}=\left[0,2\right]\right):$
 > $\mathrm{dsn2}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({1}\right){=}{5.43656271691257}\right]$ (9)
 > $\mathrm{op}\left(\left[2,2\right],\mathrm{dsn2}\right)\left(\mathrm{initial}=\frac{1}{2}\right):$
 > $\mathrm{dsn2}\left(0\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({0}\right){=}{0.500000000000000}\right]$ (10)
 > $\mathrm{dsn2}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({1}\right){=}{1.35914065144134}\right]$ (11)
 New to Maple 12, this feature now also works with range solutions and DAE problems.
 For DAE problems, the process is the same as for initial value problems, but consistency checks are performed as soon as any values are changed. Note that if the initial values are changed to inconsistent values, the solution procedure(s) will not be usable until correct values are set:
 > $\mathrm{dsn3}≔\mathrm{dsolve}\left(\left\{{x\left(t\right)}^{2}+{y\left(t\right)}^{2}=1,\mathrm{diff}\left(x\left(t\right),t,t\right)=l\left(t\right)x\left(t\right),\mathrm{diff}\left(y\left(t\right),t,t\right)=l\left(t\right)y\left(t\right)-10,x\left(0\right)=0,y\left(0\right)=-1,\mathrm{D}\left(x\right)\left(0\right)=1,\mathrm{D}\left(y\right)\left(0\right)=0\right\},\mathrm{numeric}\right)$
 ${\mathrm{dsn3}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45_dae}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (12)
 > $\mathrm{dsn3}\left(\mathrm{initial}\right)$
 $\left[{t}{=}{0.}{,}{l}{}\left({t}\right){=}{-11.}{,}{x}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{1.}{,}{y}{}\left({t}\right){=}{-1.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.}\right]$ (13)
 > $\mathrm{dsn3}\left(1\right)$
 $\left[{t}{=}{1.}{,}{l}{}\left({t}\right){=}{-10.9999995226619}{,}{x}{}\left({t}\right){=}{-0.000243191292859493}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{-0.999999878673894}{,}{y}{}\left({t}\right){=}{-0.999999970376998}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.000243191369033599}\right]$ (14)
 Choose a bad value for y(0):
 > $\mathrm{dsn3}\left(\mathrm{initial}=\left[0,11,1,0,1,1\right]\right)$
 > $\mathrm{dsn3}\left(1\right)$
 Correct it:
 > $\mathrm{dsn3}\left(\mathrm{initial}=\left[0,11,1,0,0,1\right]\right)$
 $\left[{t}{=}{0.}{,}{l}{}\left({t}\right){=}{11.}{,}{x}{}\left({t}\right){=}{1.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{0.}{,}{y}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{1.}\right]$ (15)
 > $\mathrm{dsn3}\left(1\right)$
 $\left[{t}{=}{1.}{,}{l}{}\left({t}\right){=}{-11.5367008026070}{,}{x}{}\left({t}\right){=}{-0.936291714443607}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{-0.994927567859575}{,}{y}{}\left({t}\right){=}{-0.351223327520403}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{2.65227952244895}\right]$ (16)
 For range solutions (both for ODE and DAE), the solution is recomputed for the originally specified range whenever the initial values are changed.

Parametrized problems

 It is now possible to obtain procedure solutions for parametrized ODE and DAE initial value problems with dsolve/numeric. Both the ODE/DAE defining equations, and the initial values, can depend upon the parameters.
 The problem parameters must be declared when obtaining the dsolve/numeric solution procedure, and can be set using the procedure in much the same way as the initial values. For example:
 > $\mathrm{dsn4}≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)=ay\left(x\right),y\left(\mathrm{x0}\right)=\mathrm{y0}\right\},\mathrm{numeric},\mathrm{parameters}=\left[\mathrm{x0},\mathrm{y0},a\right]\right)$
 ${\mathrm{dsn4}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (17)
 Solutions cannot be obtained until the parameters are set:
 > $\mathrm{dsn4}\left(1\right)$
 Parameter values can be queried and set as follows:
 > $\mathrm{dsn4}\left(\mathrm{parameters}\right)$
 $\left[{\mathrm{x0}}{=}{\mathrm{undefined}}{,}{\mathrm{y0}}{=}{\mathrm{undefined}}{,}{a}{=}{\mathrm{undefined}}\right]$ (18)
 > $\mathrm{dsn4}\left(\mathrm{parameters}=\left[0,1,-1\right]\right)$
 $\left[{\mathrm{x0}}{=}{0.}{,}{\mathrm{y0}}{=}{1.}{,}{a}{=}{-1.}\right]$ (19)
 > $\mathrm{dsn4}\left(0\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{1.}\right]$ (20)
 > $\mathrm{dsn4}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({x}\right){=}{0.367879356307219}\right]$ (21)
 > $\mathrm{dsn4}\left(\mathrm{parameters}\right)$
 $\left[{\mathrm{x0}}{=}{0.}{,}{\mathrm{y0}}{=}{1.}{,}{a}{=}{-1.}\right]$ (22)
 > $\mathrm{dsn4}\left(\mathrm{parameters}=\left[a=-2\right]\right)$
 $\left[{\mathrm{x0}}{=}{0.}{,}{\mathrm{y0}}{=}{1.}{,}{a}{=}{-2.}\right]$ (23)
 > $\mathrm{dsn4}\left(0\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{1.}\right]$ (24)
 > $\mathrm{dsn4}\left(1\right)$
 $\left[{x}{=}{1.}{,}{y}{}\left({x}\right){=}{0.135335201861774}\right]$ (25)
 Parameters also work for DAE problems, as well as problems with specified ranges. For DAE problems though, just as for setting of the initial data, the parameters must be consistent with the constraints of the problem:
 > $\mathrm{dsn5}≔\mathrm{dsolve}\left(\left\{{x\left(t\right)}^{2}+{y\left(t\right)}^{2}={r}^{2},\mathrm{diff}\left(x\left(t\right),t,t\right)=l\left(t\right)x\left(t\right),\mathrm{diff}\left(y\left(t\right),t,t\right)=l\left(t\right)y\left(t\right)-g,x\left(0\right)=0,y\left(0\right)=\mathrm{y0},\mathrm{D}\left(x\right)\left(0\right)=\mathrm{Dx0},\mathrm{D}\left(y\right)\left(0\right)=0\right\},\mathrm{numeric},\mathrm{parameters}=\left[\mathrm{y0},\mathrm{Dx0},g,r\right]\right)$
 ${\mathrm{dsn5}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45_dae}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (26)
 > $\mathrm{dsn5}\left(1\right)$
 > $\mathrm{dsn5}\left(\mathrm{parameters}\right)$
 $\left[{\mathrm{y0}}{=}{\mathrm{undefined}}{,}{\mathrm{Dx0}}{=}{\mathrm{undefined}}{,}{g}{=}{\mathrm{undefined}}{,}{r}{=}{\mathrm{undefined}}\right]$ (27)
 > $\mathrm{dsn5}\left(\mathrm{parameters}=\left[-2,1,10,1\right]\right)$
 > $\mathrm{dsn5}\left(1\right)$
 Repair the incorrect value
 > $\mathrm{dsn5}\left(\mathrm{parameters}=\left[\mathrm{y0}=-1\right]\right)$
 $\left[{\mathrm{y0}}{=}{-1.}{,}{\mathrm{Dx0}}{=}{1.}{,}{g}{=}{10.}{,}{r}{=}{1.}\right]$ (28)
 > $\mathrm{dsn5}\left(1\right)$
 $\left[{t}{=}{1.}{,}{l}{}\left({t}\right){=}{-10.9999995226619}{,}{x}{}\left({t}\right){=}{-0.000243191292859331}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{-0.999999878673895}{,}{y}{}\left({t}\right){=}{-0.999999970376998}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.000243191369033434}\right]$ (29)
 Note that it is not always possible to simply adjust the parameters of a problem to be consistent with the constraints, but it may also be necessary to adjust the initial conditions simultaneously. When this is the case, the initial_and_parameters keyword must be used instead. For example:
 > $\mathrm{dsn5b}≔\mathrm{dsolve}\left(\left\{{x\left(t\right)}^{2}+{y\left(t\right)}^{2}={r}^{2},\mathrm{diff}\left(x\left(t\right),t,t\right)=l\left(t\right)x\left(t\right),\mathrm{diff}\left(y\left(t\right),t,t\right)=l\left(t\right)y\left(t\right)-g,x\left(0\right)=0,y\left(0\right)=0,\mathrm{D}\left(x\right)\left(0\right)=0,\mathrm{D}\left(y\right)\left(0\right)=0\right\},\mathrm{numeric},\mathrm{parameters}=\left[g,r\right]\right)$
 ${\mathrm{dsn5b}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45_dae}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (30)
 > $\mathrm{dsn5b}\left(1\right)$
 > $\mathrm{dsn5b}\left(\mathrm{initial_and_parameters}\right)$
 $\left[{t}{=}{0.}{,}{l}{}\left({t}\right){=}{Float}{}\left({\mathrm{undefined}}\right){,}{x}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{0.}{,}{y}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.}{,}{g}{=}{\mathrm{undefined}}{,}{r}{=}{\mathrm{undefined}}\right]$ (31)
 > $\mathrm{dsn5b}\left(\mathrm{initial_and_parameters}=\left[0,0,1,-1,0,g=10,r=1\right]\right)$
 $\left[{t}{=}{0.}{,}{l}{}\left({t}\right){=}{0.}{,}{x}{}\left({t}\right){=}{0.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{1.}{,}{y}{}\left({t}\right){=}{-1.}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.}{,}{g}{=}{10.}{,}{r}{=}{1.}\right]$ (32)
 > $\mathrm{dsn5b}\left(1\right)$
 $\left[{t}{=}{1.}{,}{l}{}\left({t}\right){=}{-10.9999995226619}{,}{x}{}\left({t}\right){=}{-0.000243191292859331}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{x}{}\left({t}\right){=}{-0.999999878673895}{,}{y}{}\left({t}\right){=}{-0.999999970376998}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({t}\right){=}{0.000243191369033434}\right]$ (33)

Other Features

 In addition to the features discussed above, there are several other small interactive features available for dsolve/numeric procedures.
 > $\mathrm{dsn6}≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)-y\left(x\right)=0,y\left(1\right)=\mathrm{exp}\left(1\right)\right\},\mathrm{numeric}\right)$
 ${\mathrm{dsn6}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (34)
 > $\mathrm{dsn6}\left(0\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{0.999999757634219}\right]$ (35)
 The argument 'start' can be used to query the initial point specified for the problem:
 > $\mathrm{dsn6}\left(\mathrm{start}\right)$
 ${1.}$ (36)
 The argument 'last' can be used to query the last computed point for the solution procedure (the last computed point does not include the interactive queries described on this page). This is most useful for problems with events.
 > $\mathrm{dsn6}\left(\mathrm{last}\right)$
 $\left[{x}{=}{0.}{,}{y}{}\left({x}\right){=}{0.999999757634219}\right]$ (37)
 For range-defined problems, 'left' and 'right' can be used to query the endpoints of the range.
 > $\mathrm{dsn7}≔\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(x\right),x\right)-y\left(x\right)=0,y\left(1\right)=1\right\},\mathrm{numeric},\mathrm{range}=0..2\right)$
 ${\mathrm{dsn7}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (38)
 > $\mathrm{dsn7}\left('\mathrm{left}'\right)$
 ${0.}$ (39)
 > $\mathrm{dsn7}\left('\mathrm{right}'\right)$
 ${2.}$ (40)
 The 'method' argument can be used to query the numerical method being used to obtain the solution of the problem:
 > $\mathrm{dsn7}\left('\mathrm{method}'\right)$
 ${"rkf45"}$ (41)
 The 'numfun' argument can be used to query the number of function evaluations performed for integration from the initial point to the most recently requested solution value (supported for all solvers that support maxfun):
 > $\mathrm{dsn7}\left('\mathrm{numfun}'\right)$
 ${43}$ (42)