dsolve/numeric  find numerical solution of ordinary differential equations

Calling Sequence


dsolve(odesys, numeric, vars, options)
dsolve(numeric, procopts, options)


Parameters


odesys



set or list; ordinary differential or differentialalgebraic equation(s) and initial/boundary conditions

numeric



name; instruct dsolve to find a numerical solution

vars



(optional) any indeterminate function of one variable, or a set or list of them, representing the unknowns of the ODE problem

procopts



(required if odesys is not present) options that specify a procedure defined system (procedure, initial, start, number, and procvars). For more information, see dsolve[numeric,IVP].

options



(optional) equations of the form keyword = value





Description


•

The dsolve command with the numeric or type=numeric option finds a numerical solution for the ODE or ODE system. If the optional equation method=numericmethod is provided (where numericmethod is one of rkf45, ck45, rosenbrock, bvp, rkf45_dae, ck45_dae, rosenbrock_dae, dverk78, lsode, gear, taylorseries, mebdfi, or classical), dsolve uses that method to obtain the numerical solution.


Both initial and boundary value problems can be numerically solved, as well as initial differential algebraic problems. For a system input, the type of problem is automatically detected, but for some DAE problems it may be necessary to specify the method.


By default, a procedure is returned that can be used to obtain solution values if given the value of the independent variable.

•

The default for initial value problems (IVP) is a RungeKutta Fehlberg method that produces a fifth order accurate solution (For more information, see rkf45 or numeric,IVP). For boundary value problems (BVP), a finite difference technique with Richardson extrapolation is used (For more information, see numeric,BVP). For differentialalgebraic IVP problems (DAE), a modification of the rkf45 method is used (For more information, see dae_extension).

•

All IVP methods can be used for complexvalued IVPs with a realvalued independent variable (though for the default stiff and nonstiff IVP methods, it may be necessary to specify that the problem is complex via the complex option). None of the BVP or DAE methods can currently be used for complexvalued problems, requiring the system be converted to a real system before calling dsolve.

•

The IVP and DAE methods have additional capabilities for the returned solution procedure. Specifically, it is possible to query the last computed solution value (useful for problems with singularities), query the initial data, and change the initial data for some solution procedures (DAE methods support a subset of this). For more information, see numeric,IVP and numeric,DAE.

•

When the set of dependent variables vars is specified as a list, then this specifies the order of the dependent variables as they appear in the output. The order is otherwise alphabetical in the dependent variable name.


Options


•

The highlevel options, most common to IVPs, BVPs, and DAEs are as follows.

'output' =

keyword or array

'stiff' =

boolean

'events' =

list

'event_pre' =

keyword

'event_maxiter' =

integer

'range' =

numeric..numeric

'abserr' =

numeric or list

'relerr' =

numeric

'known' =

name or list of names

'optimize' =

boolean




'output'= keyword or array


Keyword that can take the values procedurelist, listprocedure, operator, or piecewise, or an array or Array that gives the values of the independent variable at which solution values are desired.


The default keyword is procedurelist, which gives the output from dsolve as a procedure. This procedure accepts the value of the independent variable as an argument, and it returns a list of the solution values of the form variable=value, where the lefthand sides are the names of the independent variable, the dependent variable(s) and their derivatives (for higher order equations), and the righthand sides are the corresponding computed solution values.


The listprocedure keyword gives the output as a list of equations of the form variable=procedure, where the lefthand sides are the names of the independent variable, the dependent variable(s) and derivatives, and the righthand sides are procedures that can be used to compute the corresponding solution components. This output form is most useful when the returned procedure is to be used later with, for example, fsolve.


The operator keyword gives the output as a list of equations of the form operator=procedure, where the lefthand sides are operators that can be applied to an independent variable value to give the function or derivative evaluated at a point, and the righthand sides are procedures that can be used to compute the corresponding solution components. This output form is most useful for shortcut evaluation forms where the returned list is to be evaluated at a point (for example, ).


The piecewise keyword is available only for nonstiff and stiff default IVP and DAE methods (rkf45, ck45, rosenbrock, rkf45_dae, ck45_dae, and rosenbrock_dae) and the taylorseries method. It provides output as a list of equations of the form , where the lefthand sides are the names of the independent variable, the dependent variable(s) and derivatives, and the righthand sides are piecewise polynomial functions describing the corresponding solution components. These piecewise functions are obtained from the method interpolants for each step of the computation. In addition, the form of the piecewise polynomials can be specified using an index on the piecewise output request. Specification of output=piecewise[horner] provides output in terms of hornerform polynomials (the default for taylorseries), while specification of output=piecewise[polynomial] provides output in terms of standard polynomial form (the default for all other methods). Use of this output form requires that the 'range' argument be used to specify to dsolve/numeric the desired range of the piecewise function.


Note: If an Array is used, then the output is the same as for an array except the newer Array and Matrix datatypes are used in the output. For a large number of output points and/or solution components, the output data may not be directly visible because there is a default size at which the representation of an Array or Matrix is displayed instead of an inline display of the data itself. For more information, see interface(rtablesize).


Boolean that is used only for IVP and DAE. Setting stiff=true without selecting a method specifies that the default stiff methods (rosenbrock or rosenbrock_dae) must be used instead of the default nonstiff methods (rkf45 or rkf45_dae). When the method is also specified, a consistency check is performed to verify that the method matches with the 'stiff' value. For more information on the phenomena of stiffness, see dsolve[Stiffness].


'range'= numeric...numeric


Values that specify the range of the independent variable over which solution values are desired.


For IVPs and DAEs this option is used only by the nonstiff and stiff methods (rkf45, ck45, rosenbrock, rkf45_dae, ck45_dae, rosenbrock_dae) and the taylorseries method. It has two purposes for proceduretype output. If 'range' is used, then the call to dsolve computes the solution over the desired range before returning, storing that solution for later calls to the returned procedure, which then compute the return values through interpolation.


 When computing a numerical solution for a problem that has large regions where the solution is changing slowly, and small regions where the solution is changing rapidly, use of 'range' combined with the refine option of odeplot (rkf45*, ck45*, and rosenbrock* only) allows better plotting of the details of the solution. If 'range' is not used, then the call to dsolve returns a procedure that does not store the computed solution, but rather computes the solution whenever a point is requested.


 For longtime integration problems it is suggested that 'range' not be used, as the storage of the entire solution can consume a fair bit of memory.


For the BVP method, this option is only needed when the BVP method is to be used to solve an IVP with a global error bound, as for BVP the information can be inferred from the boundary conditions in deqns. For more information, see numeric,BVP.


'abserr'= numeric or list


Numeric value that gives a limit on the absolute error tolerance for a successful step in the IVP and DAE cases, and a measure of the maximum error between the computed solution and the exact solution in the BVP case (in all but exceptional systems). It is supported by all methods except the classical methods (as all classical methods are implemented with a fixed step size and no error control). The list form of abserr is available for the rkf45*, ck45*, rosenbrock*, and mebdfi IVP and DAE methods, and allows specification of absolute error tolerances that are different for each dependent variable, or for each solution component. More detail on this can be found in the dsolve[numeric,IVP] page and the dsolve[Error_Control] page.


Numeric value that gives a limit on the relative error tolerance for a successful step for an IVP or DAE. This option works in conjunction with 'abserr'. It is supported by all methods except classical, taylorseries, and bvp.


Defaults for 'abserr' and 'relerr' are specific to each method, but it should be noted that the default error tolerance for the nonstiff methods rkf45 and ck45 is now fixed (rather than controlled by the value of Digits).


'known'= name or list of names


Provides a list of functions that should be considered as known when examining the system. This allows for specification of a system containing userdefined functions. Each user defined function must always return numerical values when given numeric input, and must return unevaluated when given name input. For an illustration of the use of this option, see the Examples section below.


Note: In most cases, use of a system with a userdefined function prevents the use of evalhf within dsolve, so obtaining a solution using this facility will run noticeably slower than specification of the system in terms of known functions (when it is possible to express the system in this way).


All methods except taylorseries, rosenbrock, and rosenbrock_dae support this option directly, but for these two methods additional information is required. The key problem is that these two methods require information on the derivatives of the input ODE system, which is not directly available when functions are procedure defined. It is still possible to use these methods with 'known', as long as the derivatives of the function are defined via use of one or more `diff/` rules. The rosenbrock method requires only a single derivative, but the taylorseries method requires derivatives to arbitrary order, so with taylorseries it is useful only if some finite derivative of the 'known' functions can be represented as a function instead of a procedure, in which case, all derivatives up to that function derivative must have a diff rule defined. The rosenbrock_dae method may require more than a single derivative, as the DAE preprocessing may need to differentiate the input system.


For taylorseries, rosenbrock, and rosenbrock_dae use of multiple argument functions, or functions that also depend on the dependent variables or derivatives of the problem are tricky, and have some limitations. The details of this are deferred to the respective help pages.


Boolean that tells dsolve to optimize the input system for computation. This adds an upfront cost, with the possible reward that the core computation itself will be faster. This is false by default for IVP and BVP problems, and true by default for DAE problems (which typically derive the most benefit from optimization). Systems containing conditional evaluation functions (such as piecewise) should not use optimize=true, as this will sometimes result in a slower computation. This option is available only for system defined problems, and for all methods except taylorseries (which uses its own form of optimization).

•

All other options, including options for specification of procedures for the evaluation of the ODE system, and options specific to IVP or BVP are discussed in dsolve[numeric,IVP] and dsolve[numeric,BVP], or the help pages specific to each method.



Notes


•

When Digits<=, numerical solutions are computed in double precision (hardware floats). This is the default, as on initialization Maple sets Digits to 10. Explicit setting of Digits> causes dsolve to compute numerical solutions using Maple floats instead of hardware floats. The precision of a computation is fixed in the call to dsolve, so for procedure outputs, once the procedure is created, further changes to the setting of Digits should have no effect on the computed solution.


Numerical solutions can be used in combination with fsolve, but the Digits setting on the call to fsolve must be lower (usually by 5 or more) than the precision for the dsolve procedure (because fsolve requires a higher accuracy on the residual than the current Digits setting). The rkf45, ck45, rosenbrock, and taylorseries methods, when computing solution values with an interpolant, work around this problem by computing the interpolant with the current setting of Digits when called from fsolve. An example of the problem is presented in the last example below.

•

Results can be plotted by using the odeplot function in the plots package.

•

ODE systems can also be interactively solved and plotted with the dsolve[interactive] Maplet interface.




Examples


Solve a system of ODEs
>


>


>


 (1) 
If you specify the set of dependent variables as a list, those variables appear in the same order in the output.
>


>


 (2) 
Straightforward second order IVP:
>


 (3) 
>


>


 (4) 
>


 (5) 
>


 (6) 
>


 (7) 
Same second order IVP with operator output:
>


 (8) 
>


 (9) 
>


 (10) 
>


 (11) 
First order IVP:
>


 (12) 
>


 (13) 
>


 (14) 
First order IVP with piecewise output:
>


 (15) 
Stiff nonlinear problem:
>


 (16) 
>


 (17) 
Linear BVP:
>


 (18) 
>


 (19) 
>


 (20) 
>


 (21) 
>


 (22) 
Nonlinear BVP:
>


 (23) 
>


 (24) 
DAE:
>


 (25) 
>


 (26) 
>


 (27) 
Use with fsolve:
>


 (28) 
>


 (29) 
>


 (30) 
>


 (31) 
Attempt with same Digits setting, returns unevaluated.
>

fsolve(yproc(x)=1e5, x=4..7);

 (32) 
The same command with Digits set to 15 succeeds.
>


 (33) 
>

fsolve(yproc(x)=1e5, x=4..7);

 (34) 
>


 (35) 
Use of known option:
>

f := proc(x) local t;
if not type(evalf(x),'numeric') then
'procname'(x);
else
evalf(Int(exp(t^2/10),t=0..x));
end if;
end proc;

 (36) 
Note that the procedure is set up for an unevaluated return if the input is not numeric.
>


 (37) 
>


This failed because 'known' was not specified. Here, it is specified.
>


 (38) 
>


 (39) 
>


 (40) 
A method that requires derivatives,
>


which failed because a differentiation rule is required. We then clear the remember table of diff and define this as:
>


>

`diff/f` := proc()
# Chain rule
diff(args[1],args[2])*exp((args[1])^2/10);
end proc:

which works as follows:
>


 (41) 
>


 (42) 
and now:
>


 (43) 
>


 (44) 
>


 (45) 


See Also


Digits, dsolve/dae_extension, dsolve/Error_Control, dsolve[ck45], dsolve[classical], dsolve[dverk78], dsolve[Events], dsolve[gear], dsolve[interactive], dsolve[lsode], dsolve[maxfun], dsolve[mebdfi], dsolve[numeric,BVP], dsolve[numeric,DAE], dsolve[numeric,interactive], dsolve[numeric,IVP], dsolve[rkf45], dsolve[rosenbrock], dsolve[Stiffness], dsolve[taylorseries], fsolve, interface, plots[odeplot]


References



Ascher, U.; Mattheij, R.; and Russell, R. "Numerical Solution of Boundary Value Problems for Ordinary Differential Equations." SIAM Classics in Applied Mathematics. Vol. 13. (1995).


Ascher, U., and Petzold, L. "Computer Methods for Ordinary Differential Equations and DifferentialAlgebraic Equations." SIAM, Philadelphia. 1998.


Bailey, P.B.; Shampine, L.F.; and Waltman, P.E. Nonlinear Two Point Boundary Value Problems. New York: Academic Press, 1968.


Boyce, W.E., and DiPrima, R.C. Elementary Differential Equations and Boundary Value Problems. New York: John Wiley & Sons, 1997.


Cash, J.R. "The Integration of Stiff IVP in ODE Using Modified Extended BDF." Computers and Mathematics with Applications. Vol. 9. (1983): 645657.


Gear, C.W. Numerical Initial Value Problems in Ordinary Differential Equations. PrenticeHall, 1971.


Hindmarsh, Alan C.; Stepleman, R.S.; et al, eds. Odepack, a Systemized Collection of ODE Solvers. Amsterdam: NorthHolland, 1983.


Hubbard J.H., and West, B.H. Differential Equations: A Dynamical Systems Approach. New York: Springer, 1990. Part I. One Dimensional Equations.


Hull, T.E.; Enright, W.H.; Fellen, B.M.; and Sedgwick, A.E. "Comparing Numerical Methods for Ordinary Differential Equations." SIAM J. Numer. Anal. Vol. 9. (1972): 603637.


Shampine, L.F., and Corless, R.M. "Initial Value Problems for ODEs in Problem Solving Environments." J. Comp. Appl. Math. Vol. 125(12). (2000): 3140.


