Interactive features of numeric ODE/DAE solutions
Description
Examples
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.
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:
dsn≔dsolve⁡diff⁡y⁡x,x−y⁡x=0,y⁡0=1,numeric
dsn ≔ procx_rkf45...end proc
dsn⁡1
x=1.,y⁡x=2.71828133411964
dsn⁡initial
x=0.,y⁡x=1.
dsn2≔dsolve⁡diff⁡y⁡x,x−y⁡x=0,y⁡0=1,numeric,output=operator
dsn2≔x=procx...end proc,y=procx...end proc
dsn2⁡1
x=1.,y⁡1=2.71828133411964
dsn2⁡initial
x⁡initial=0.,y⁡initial=1.
In addition, initial values can be changed by calling the solution procedure with an equation of the form initial=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 x0,y⁡x0).
dsn⁡initial=0,2
x=0.,y⁡x=2.
x=1.,y⁡x=5.43656271691257
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:
op⁡1,2,dsn2⁡initial=0,2:
x=1.,y⁡1=5.43656271691257
op⁡2,2,dsn2⁡initial=12:
dsn2⁡0
x=0.,y⁡0=0.500000000000000
x=1.,y⁡1=1.35914065144134
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:
dsn3≔dsolve⁡x⁡t2+y⁡t2=1,diff⁡x⁡t,t,t=l⁡t⁢x⁡t,diff⁡y⁡t,t,t=l⁡t⁢y⁡t−10,x⁡0=0,y⁡0=−1,D⁡x⁡0=1,D⁡y⁡0=0,numeric
dsn3 ≔ procx_rkf45_dae...end proc
dsn3⁡initial
t=0.,l⁡t=−11.,x⁡t=0.,ⅆⅆtx⁡t=1.,y⁡t=−1.,ⅆⅆty⁡t=0.
dsn3⁡1
t=1.,l⁡t=−10.9999995226619,x⁡t=−0.000243191292859493,ⅆⅆtx⁡t=−0.999999878673894,y⁡t=−0.999999970376998,ⅆⅆty⁡t=0.000243191369033599
Choose a bad value for y(0):
dsn3⁡initial=0,11,1,0,1,1
Error, (in `dsolve/numeric/DAE/checkconstraints`) the initial conditions do not satisfy the algebraic constraints error = 1., tolerance = .200e-5, constraint = x(t)^2+y(t)^2-1 error = 1., tolerance = .100e-5, constraint = x(t)*diff(x(t),t)+y(t)*diff(y(t),t)
Error, (in dsn3) parameters must be initialized before solution can be computed
Correct it:
dsn3⁡initial=0,11,1,0,0,1
t=0.,l⁡t=11.,x⁡t=1.,ⅆⅆtx⁡t=0.,y⁡t=0.,ⅆⅆty⁡t=1.
t=1.,l⁡t=−11.5367008026070,x⁡t=−0.936291714443607,ⅆⅆtx⁡t=−0.994927567859575,y⁡t=−0.351223327520403,ⅆⅆty⁡t=2.65227952244895
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:
dsn4≔dsolve⁡diff⁡y⁡x,x=a⁢y⁡x,y⁡x0=y0,numeric,parameters=x0,y0,a
dsn4 ≔ procx_rkf45...end proc
Solutions cannot be obtained until the parameters are set:
dsn4⁡1
Error, (in dsn4) parameters must be initialized before solution can be computed
Parameter values can be queried and set as follows:
dsn4⁡parameters
x0=undefined,y0=undefined,a=undefined
dsn4⁡parameters=0,1,−1
x0=0.,y0=1.,a=−1.
dsn4⁡0
x=1.,y⁡x=0.367879356307219
dsn4⁡parameters=a=−2
x0=0.,y0=1.,a=−2.
x=1.,y⁡x=0.135335201861774
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:
dsn5≔dsolve⁡x⁡t2+y⁡t2=r2,diff⁡x⁡t,t,t=l⁡t⁢x⁡t,diff⁡y⁡t,t,t=l⁡t⁢y⁡t−g,x⁡0=0,y⁡0=y0,D⁡x⁡0=Dx0,D⁡y⁡0=0,numeric,parameters=y0,Dx0,g,r
dsn5 ≔ procx_rkf45_dae...end proc
dsn5⁡1
Error, (in dsn5) parameters must be initialized before solution can be computed
dsn5⁡parameters
y0=undefined,Dx0=undefined,g=undefined,r=undefined
dsn5⁡parameters=−2,1,10,1
Error, (in `dsolve/numeric/DAE/checkconstraints`) the initial conditions do not satisfy the algebraic constraints error = 3., tolerance = .400e-5, constraint = x(t)^2+y(t)^2-r^2
Repair the incorrect value
dsn5⁡parameters=y0=−1
y0=−1.,Dx0=1.,g=10.,r=1.
t=1.,l⁡t=−10.9999995226619,x⁡t=−0.000243191292859331,ⅆⅆtx⁡t=−0.999999878673895,y⁡t=−0.999999970376998,ⅆⅆty⁡t=0.000243191369033434
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:
dsn5b≔dsolve⁡x⁡t2+y⁡t2=r2,diff⁡x⁡t,t,t=l⁡t⁢x⁡t,diff⁡y⁡t,t,t=l⁡t⁢y⁡t−g,x⁡0=0,y⁡0=0,D⁡x⁡0=0,D⁡y⁡0=0,numeric,parameters=g,r
dsn5b ≔ procx_rkf45_dae...end proc
dsn5b⁡1
Error, (in dsn5b) parameters must be initialized before solution can be computed
dsn5b⁡initial_and_parameters
t=0.,l⁡t=Float⁡undefined,x⁡t=0.,ⅆⅆtx⁡t=0.,y⁡t=0.,ⅆⅆty⁡t=0.,g=undefined,r=undefined
dsn5b⁡initial_and_parameters=0,0,1,−1,0,g=10,r=1
t=0.,l⁡t=0.,x⁡t=0.,ⅆⅆtx⁡t=1.,y⁡t=−1.,ⅆⅆty⁡t=0.,g=10.,r=1.
Other Features
In addition to the features discussed above, there are several other small interactive features available for dsolve/numeric procedures.
dsn6≔dsolve⁡diff⁡y⁡x,x−y⁡x=0,y⁡1=exp⁡1,numeric
dsn6 ≔ procx_rkf45...end proc
dsn6⁡0
x=0.,y⁡x=0.999999757634219
The argument 'start' can be used to query the initial point specified for the problem:
dsn6⁡start
1.
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.
dsn6⁡last
For range-defined problems, 'left' and 'right' can be used to query the endpoints of the range.
dsn7≔dsolve⁡diff⁡y⁡x,x−y⁡x=0,y⁡1=1,numeric,range=0..2
dsn7 ≔ procx_rkf45...end proc
dsn7⁡left
0.
dsn7⁡right
2.
The 'method' argument can be used to query the numerical method being used to obtain the solution of the problem:
dsn7⁡method
rkf45
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):
dsn7⁡numfun
43
See Also
dsolve[Events]
dsolve[maxfun]
dsolve[numeric,DAE]
dsolve[numeric,IVP]
dsolve[numeric]
Download Help Document