Maple Dsolve Numeric
Maple Dsolve Numeric
Maple Dsolve Numeric
value problems
Calling Sequence
dsolve(daesys, numeric, vars, options)
Parameters
daesys - set or list; ordinary differential equation(s), algebraic equation(s) and
initial conditions
numeric -
vars
daesys
options -
Description
The dsolve command with the numeric or type=numeric option and a real-valued
differential-algebraic initial value problem (DAE IVP) finds a numerical solution for
the DAE IVP. If the optional equation method=numericmethod is provided (where
numericmethod is one of rkf45_dae, rosenbrock_dae, or mebdfi, dsolve uses that
method to obtain the numerical solution.
In most cases dsolve is able to detect if the problem is a DAE system, as opposed to
an ODE system, namely the cases in which pure algebraic equations in the dependent
variables are present. If the input is a DAE system containing no purely algebraic
equations, the method must be included to specify that the system is a DAE system.
Constrained mechanical systems often give rise to DAE problems. (See the pendulum
example below.)
The return value of dsolve and the following high level or common options are
discussed in dsolve[numeric] and dsolve[Error_Control].
'output'
keyword or array
'range'
numeric..numeric
'abserr'
numeric or list
'relerr'
numeric
'stiff'
boolean
'known'
'optimize' =
boolean
The exception is that for the DAE solvers the absolute error tolerance can be specified
as a per-component list. For expected behavior, the variables of the problem must also
be specified as a list, and the entries of 'abserr' must correspond 1-1 to the variables
in the list, or to the variables in the system converted to first order using the order of
the variables in the list. For more information, see the ?dsolve[numeric,IVP] help
page.
The default DAE IVP method is a modified Runge-Kutta Fehlberg method, which
uses a base order 4-5 method, but has been modified to find solutions for DAE
problems. The default stiff method is a Rosenbrock method, which uses a base order
3-4 method. For a description of the modifications done to these methods in
extending them to DAE solution, see the ?dae_extension help page. The other method
available for DAE IVP is the dsolve[mebdfi] method, which is short for Modified
Extended Backward-Differentiation Formula Implicit method.
In general, the DAE IVP solvers are very similar to the standard differential IVP
solvers, so this page is primarily concerned with outlining the differences between
them.
The DAE solvers are currently restricted to finding solutions for real-valued
problems.
For use of any of the methods, the specified initial conditions must satisfy all hidden
constraints of the system (that is, they must be a consistent set of initial conditions
with respect to the DAE). In the event that they do not, an error results, and
information is provided on the unsatisfied condition.
In some cases, it may be necessary to use fsolve to compute consistent initial
conditions for the problem.
If the ?dae_extension methods are in use, the differential option is set to true, and the
system is sufficiently linear in the algebraic variables (i.e., variables which have no
derivatives appearing in the input system), it is possible to skip initial conditions for
those variables. If the initial conditions are skipped when they are required, an error
will be produced.
The following options are also available for some or all of the DAE methods:
'minstep'
numeric
'maxstep'
numeric
'initstep'
numeric
'startinit'
boolean
'events'
list
'event_pre'
keyword
'event_maxiter' =
integer
'projection'
boolean
'differential'
boolean
'implicit'
boolean
'parameters'
list of names
Examples
As a first example, we consider the problem of modeling the dynamics of a mass on a
string of unit length in 2-D Cartesian coordinates (the pendulum problem). We let r be
the position of the mass on the string, and v the velocity:
> VectorCalculus[SetCoordinates](cartesian):
> VectorCalculus[BasisFormat](false):
> r := VectorCalculus[Vector]([x(t),y(t)]);
3
x( t )
y( t )
r :=
> v := VectorCalculus[diff](r,t);
d x( t )
dt
v :=
y
(
t
)
dt
Now we want to construct the DAE system using the Euler-Lagrange formulation, so we
compute the kinetic energy T and the potential energy V as:
> T := m/2*VectorCalculus[DotProduct](v,v);
1
T := m
2
d x( t ) d y( t )
dt
dt
> V := m*g*y(t);
V := m g y( t )
where m is the mass, and g is the gravitational constant (we will use 9.8). The Lagrangian
and modified Lagrangian are given by:
> L := T-V;
1
L := m
2
d x( t ) d y( t )
dt
dt
m g y( t )
> ML := L - lambda(t)*con;
1
ML := m
2
d x( t ) d y( t )
dt
dt
2
2
2
m g y( t )( t ) ( x( t ) y( t ) l )
d2
d2
2
2
2
x
(
t
)
,
x
(
t
)
y
(
t
)
l
,
m
g
(
t
)
y
(
t
)
m
y( t ) }
2
2
dt
dt
Q := { 2 ( t ) x( t )m
d2
( t ) x( t )
x( t )2
2
m
dt
d2
m g2 ( t ) y( t )
2 y( t )
m
dt
Now we have the equations of motion for the pendulum. Next, we need to determine
consistent initial conditions. To do so, we must identify any hidden constraints of the
system. These are easy to find, as we have only one constraint.
> Dcon := diff(EQc,t);
d
d
x( t ) 2 y( t ) y( t )
d
t
d
Dcon:= 2 x( t )
d
x( t )2 ( t )
d
y( t ) ( m g2 ( t ) y( t ) )
x( t ) 4
2 y( t ) 2
d
t
m
d
t
m
DDcon:= 2
Our initial conditions must satisfy EQc, Dcon, and DDcon at the initial point, leaving
only 2 degrees of freedom for the conditions. So for a pendulum starting at the minimum
value of y(0) = -l having an initial horizontal velocity of D(x)(0) = vx, we get:
> sys := {y(0)=-l,D(x)(0)=vx} union
eval(convert({EQc,Dcon,DDcon},D),t=0);
sys := { 2 x( 0 ) D( x )( 0 )2 y( 0 ) D( y )( 0 ), x( 0 )2y( 0 )2l2,
2 D( x )( 0 )24
x( 0 )2 ( 0 )
y( 0 ) ( m g2 ( 0 ) y( 0 ) )
2 D( y )( 0 )22
, y( 0 )l,
m
m
D( x )( 0 )vx}
So we consider the above with a pendulum of unit length l = 1 having unit mass m = 1
and an initial horizontal velocity of vx = 1/10, giving us the DAE system and initial
conditions:
> dsys := eval({EQx,EQy,EQc},{l=1,m=1,g=9.8,vx=1/10});
dsys := { x( t )2y( t )21,
d2
d2
x
(
t
)
(
t
)
x
(
t
)
,
y( t )9.82 ( t ) y( t ) }
dt2
dt2
> dsol1(1/2);
t0.500000000000000
, ( t )4.89750023744205887
, x( t )0.0319392547405407887
,
d
x( t )0.000564531449666508191
, y( t )-0.999489811893806701
,
dt
d
y( t )0.0000180382736946334369
dt
> dsol1(1);
t1., ( t )4.90499904949563259
, x( t )0.000360893004470803490
,
d
x( t )-0.0999936779200488873
, y( t )-0.99999993487231431
,
dt
d
y( t )-0.0000360870084253994927
dt
> dsol2(1/2);
t0.500000000000000
, ( t )4.89750019118586088
, x( t )0.0319392364763693773
,
d
x( t )0.000564626004686089771
, y( t )-0.999489813543333439
,
dt
d
y( t )0.0000180482728717063205
dt
> dsol2(1);
t1., ( t )4.90499906207810721
, x( t )0.000360968463263104937
,
d
x( t )-0.0999936779452163804
, y( t )-0.99999993669131815
,
dt
d
y( t )-0.0000360897908606885759
dt
> dsol3(1/2);
t0.500000000000000
, ( t )4.89750245194350509
, x( t )0.0319388403694855147
,
d
x( t )0.000564871203422257005
, y( t )-0.999489825189509129
,
dt
d
y( t )0.0000180670454630691393
dt
> dsol3(1);
t1., ( t )4.90497944724429935
, x( t )0.000361097312194549836
,
d
x( t )-0.0999925039194764775
, y( t )-0.99999993426187950
,
dt
d
y( t )-0.0000359881610159317974
dt
Now consider a similar problem as above, but in addition add a second mass supported
from the first by another string, this one of length 1/2 (the double pendulum). The system
can be obtained and solved as:
> dsysd := {
diff(x1(t),t,t)
+2*lambda1(t)*x1(t)
+2*lambda2(t)*(x1(t)-x2(t)),
diff(y1(t),t,t)+9.8+2*lambda1(t)*y1(t)
+2*lambda2(t)*(y1(t)-y2(t)),
diff(x2(t),t,t)
-2*lambda2(t)*(x1(t)-x2(t)),
diff(y2(t),t,t)+9.8
-2*lambda2(t)*(y1(t)-y2(t)),
x1(t)^2+y1(t)^2-1,
(x1(t)-x2(t))^2+(y1(t)-y2(t))^2-1/4
};
1
d2
dsysd:= {
d2
d2
d2
-3
ics := { x1( 0 )0, x2( 0 )0, y1( 0 )-1, y2( 0 ) , D( x1)( 0 )-3, D( x2)( 0 )4, D( y1)( 0 )0,
2
D( y2)( 0 )0}
See Also
dsolve/dae_extension, dsolve/Error_Control, dsolve[Events], dsolve[maxfun],
dsolve[mebdfi], dsolve[numeric,interactive], dsolve[numeric,IVP], dsolve[numeric],
dsolve[rkf45], dsolve[rosenbrock], dsolve[Stiffness], plots[odeplot]
Parameters
odesys
- set or list; ordinary differential or differential-algebraic equation(s) and
initial/boundary conditions
numeric
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,
Options
The high-level 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'
'optimize'
= boolean
10
11
The other columns are values of the dependent variable(s) and derivatives
corresponding to the vector of names in [1, 1]. Row i of this matrix is the vector
containing both the value of the independent variable and the values of the dependent
variables evaluated at element i of the output array.
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).
'stiff'= boolean
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 non-stiff 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].
'events'= list
'event_pre'= keyword
'event_maxiter'= integer
Arguments that are available only for real-valued IVPs or DAEs using the non-stiff
and stiff default methods, rkf45, rosenbrock, rkf45_dae, or rosenbrock_dae, and are
used to specify and control the behavior of events. These options are discussed in
detail in dsolve[Events].
'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 non-stiff and stiff default methods
(rkf45, rosenbrock, rkf45_dae, rosenbrock_dae) and the taylorseries method. It has
two purposes for procedure-type 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.
Notes:
- 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* 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 long-time integration problems it is suggested that 'range' not be used, as the
storage of the entire solution can consume a fair bit of memory.
12
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*, 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.
'relerr'= numeric
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 default non-stiff rkf45 method is now fixed
(rather than controlled by the value of Digits).
For a detailed discussion about error control, see dsolve[Error_Control].
'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 user-defined 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 user-defined 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.
13
Notes
Examples
Set of dependent variables specified as a list.
> dsys := {diff(x(t),t)=y(t),diff(y(t),t)=x(t),x(0)=1,y(0)=0}: #default alphabetical
> dsn1 := dsolve(dsys,numeric):
14
> dsn1(1);
[ t1., x( t )0.540302331775852962
, y( t )-0.841471101157619694
]
:= (t+1)^2*diff(y(t),t,t) + (t+1)*diff(y(t),t)
+ ((t+1)^2-0.25)*y(t) = 0;
d
d2
y( t ) ( t1 ) y( t ) ( ( t1 )20.25) y( t )0
2
dt
dt
deq1:= ( t1 )2
> ic1
:= y(0) = 0.6713967071418030,
D(y)(0) = 0.09540051444747446:
> dsol1(0);
d
t0., y( t )0.671396707141803
, y( t )0.0954005144474745
dt
> dsol1(0.5);
d
t0.5, y( t )0.649838013736888986
, y( t )-0.170529562812813923
dt
15
> dsol1(1);
d
t1., y( t )0.513016090104812750
, y( t )-0.363039820324437268
dt
> dsol1b(0);
[ t0., y( 0 )0.671396707141803
, D( y )( 0 )0.0954005144474745
]
> dsol1b(0.5);
[ t0.5, y( 0.5)0.649838013736888986
, D( y )( 0.5)-0.170529562812813923
]
> dsol1b(1);
[ t1., y( 1 )0.513016090104812750
, D( y )( 1 )-0.363039820324437157
]
16
x0.499406940429397
( x0.0277621231571284
)2
0.0145000345534934
( x0.0277621231571284
)3
0.133835295525126
( x0.0277621231571284
)4 , x0.0555242463142568005
0.9891015521303121.14719850212164
x0.481091117077175
( x0.149013262847986
)2
0.0904918749076433
( x0.149013262847986
)3
0.172313265605643
( x0.149013262847986
)4 , x0.242502279381714925
0.9483974661047881.31597042276291
x0.387428683672683
( x0.340057388023573
)2
0.244571952691719
( x0.340057388023573
)3
0.220713724711619
( x0.340057388023573
)4 , x0.437612496665429673
0.8974252168155321.43475629978265
x0.183288214134115
( x0.541367533479570
)2
0.432634746414217
( x0.541367533479570
)3
0.225886958082298
( x0.541367533479570
)4 , x0.645122570293710451
0.890827299363461.44839243200460
x0.133255972486488
( x0.743628540879176
)2
0.598745668467567
( x0.743628540879176
)3
0.155195536908010
( x0.743628540879176
)4 , x0.842134511464641689
0.981744432890901.34133782274070
x0.477242160985022
( x0.921067255732321
)2
0.673533874998910
( x0.921067255732321
)3
0.0140365572679978
( x0.921067255732321
)4 , x1.
undefined, otherwise]
d
x( t )x( t )2t6, x( 0 )-0.1
dt
[ t, x( t ) ]
0.
-0.100000000000000006
0.250000000000000000-0.0975697047501167536
dsol3:=
0.500000000000000000-0.0963407325327339248
0.750000000000000000-0.111744790112399378
1.
-0.229279026435938033
Linear BVP:
> dsol4 := dsolve([diff(y(x),x,x) = 3*y(x),
y(0) = 1, y(2) = 1.2], numeric);
dsol4:= proc(x_bvp) ... end proc
> dsol4(0);
d
x0., y( x )0.99999999999999956
, y( x )-1.60520425463385008
dx
> dsol4(0.5);
d
x0.5, y( x )0.492273627127113922
, y( x )-0.551072761778112929
dx
> dsol4(1);
d
x1., y( x )0.377412857949489755
, y( x )0.0632677085684644064
dx
> dsol4(2);
d
x2., y( x )1.20000000000000129
, y( x )1.97400119243652483
dx
Nonlinear BVP:
> dsys5 := {diff(y(x),x,x) + abs(y(x)) = 0, D(y)(0) = 1,
y(1) = -1};
d2
y( x ) y( x ) 0, y( 1 )-1, D( y )( 0 )1 }
dx2
dsys5:= {
18
x, y( x ), d y( x )
dx
0. -1.40964842958752423 1.00000000000000044
dsol5:= 0.25 -1.201317539681559190.675318544177146429
0.5 -1.068460865510630690.393064786112398645
0.75 -1.002731527130149350.135505794809609836
1. -0.99999999999999989-0.113539882361525873
DAE:
> dsys6:= {
diff(x(t),t,t) = -2*lambda(t)*x(t),
diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
x(t)^2+y(t)^2 = 1,
x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0};
dsys6:= { x( t )2y( t )21,
d2
d2
2
x
(
t
)
(
t
)
x
(
t
)
,
2
2 y( t )2 ( t ) y( t ) , x( 0 )0, y( 0 )-1,
dt
dt
1
D( x )( 0 ) , D( y )( 0 )0 }
10
> dsol6(1);
t1., ( t )4.93980220700398576
, x( t )0.633673384333266021
10-5,
d
x( t )-0.100000064975738170
, y( t )-0.99999999997887001
,
dt
d
y( t )-0.633673070599169403
10-6
dt
d
y( x )2 y( x ), y( 0 )1 }
dx
19
20
end proc;
f := proc(x)
local t;
if not type( evalf( x ), 'numeric' ) then'procnamex
'( ) end proc
else evalf( Int( exp( 1/10t^2 ), t0 .. x ) )
end if
Note that the procedure is set up for an unevaluated return if the input is not numeric.
> dsys8 := {diff(y(x),x)=y(x)+f(x), y(0)=0};
dsys8:= {
d
y( x )y( x )f( x ), y( 0 )0 }
dx
> dsol8(1);
[ x1., y( x )0.708149294799616413
]
> dsol8(2);
[ x2., y( x )4.19167993111609594
]
which failed because a differentiation rule is required. We then clear the remember table
of diff and define this as:
> forget(diff);
> `diff/f` := proc()
# Chain rule
21
diff(args[1],args[2])*exp(-(args[1])^2/10);
end proc:
which works as follows:
> diff(f(sin(x)),x);
cos( x ) e
( 1/10 sin( x )2 )
> diff(Int(exp(-t^2/10),t=0..sin(x)),x);
cos( x ) e
2
( 1/10 sin( x ) )
and now:
> dsol8b := dsolve(dsys8, numeric, method=rosenbrock,
known=f);
dsol8b:= proc(x_rosenbrock
) ... end proc
> dsol8b(1);
[ x1., y( x )0.708149269188471653
]
> dsol8b(2);
[ x2., y( x )4.19168036703642688
]
See Also
Digits, dsolve/dae_extension, dsolve/Error_Control, 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 Differential-Algebraic 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.
22
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): 645-657.
Gear, C.W. Numerical Initial Value Problems in Ordinary Differential Equations.
Prentice-Hall, 1971.
Hindmarsh, Alan C.; Stepleman, R.S.; et al, eds. Odepack, a Systemized Collection
of ODE Solvers. Amsterdam: North-Holland, 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):
603-637.
Shampine, L.F., and Corless, R.M. "Initial Value Problems for ODEs in Problem
Solving Environments." J. Comp. Appl. Math. Vol. 125(1-2). (2000): 31-40.
Calling Sequence
dsolve(odesys, numeric, method=classical)
dsolve(odesys, numeric, method=classical[choice], vars, options)
dsolve(numeric, method=classical[choice], procopts, options)
Parameters
odesys
initial conditions
numeric
solution
method=classical
method=classical[choice] -
vars
23
Description
heunform is the Heun formula (also known as the improved Euler method). It uses
the forward Euler method to predict the solution, and then applies the trapezoid rule
as a corrector. It is specified by the pair of equations:
Yp
impoly is the improved polygon method (also known as the modified Euler method),
as specified by the equation:
Y[n+1] = Y[n] + h*(f(t[n]+h/2, Y[n]+(h/2)*f(t[n],Y[n])))
= f(t[n], Y[n])
k2
= f(t[n]+h, Y[n]+h*k1)
= f(t[n], Y[n])
k2
= f(t[n]+(h/2), Y[n]+(h/2)*k1)
k3
= f(t[n]+h, Y[n]+h*(-k1+2*k2))
24
= f(t[n], Y[n])
k2
= f(t[n]+h/2, Y[n]+(h/2)*k1)
k3
= f(t[n]+h/2, Y[n]+(h/2)*k2)
k4
= f(t[n]+h, Y[n]+h*k3)
keyword or array
'known'
'maxfun'
integer
'number'
integer
'procedure'
procedure
'start'
numeric
'initial'
array
'procvars'
list
'startinit'
boolean
'implicit'
boolean
'optimize'
boolean
'stepsize'
numeric
25
'corrections' =
integer
'output'
Specifies the desired output from dsolve, and the known option specifies userdefined known functions. For more information, see dsolve[numeric].
'maxfun'
Specifies a maximum on the number of evaluations of the right-hand side of the first
order ODE system. This option can be disabled by specifying maxfun=0. The default
value for classical methods is 50000. For more information, see dsolve[maxfun].
'number', 'procedure', 'start', 'initial', and 'procvars'
These options are used to specify the IVP using procedures. For more information,
see dsolve[numeric,IVP].
'startinit','implicit', and 'optimize'
These options control the method and behavior of the computation. For more
information on the first two, see dsolve[numeric,IVP], for the last, see
dsolve[numeric].
'stepsize'
Specifies the static size of each step. Note that classical does not use error correction
estimates to adapt the step size. The default step size is h = min((T0-Tf)/3, 0.005) for
forward integration and h = max((T0-Tf)/3, -0.005) for backward integration,
respectively, where the problem is solved over the interval from T0 to Tf.
'corrections'
A positive integer that specifies the number of corrections that should be applied for
the abmoulton method at each step. It is recommended that this number not exceed 4
(values greater than 4 generally do not produce more accurate results, and result in
longer running times).
Results can be plotted using the odeplot function in the plots package.
Examples
> dsys1 := diff(y(t),t$3) = y(t)+diff(x(t),t),
diff(x(t),t$2) = x(t)*y(t)-diff(y(t), t$2);
dsys1:=
2
2
d3
d x( t ) , d x( t )x( t ) y( t ) d y( t )
y
(
t
)
y
(
t
)
dt
dt2
dt2
dt3
26
> ans1(1.0);
d
, x( t )18.7876915350014215
,
t1.0, x( t )13.1246093792715683
dt
d
d2
y( t )3.76283413230601260
, y( t )5.31760397608216362
, 2 y( t )10.2504683623596353
dt
dt
d2
y( x )y( x )
dx2
27
x, y( x ), d y( x )
dx
2
y
(
t
)
dt3 y( t ) y( t ) t }
dt4
deq3:= {
( 3)
> sol3(0);
3.56
> sol3(0.56);
9.87504792480694960
See Also
dsolve[dverk78], dsolve[gear], dsolve[lsode], dsolve[maxfun], dsolve[numeric],
dsolve[numeric,IVP], plots[odeplot], dsolve[rkf45], dsolve[rosenbrock],
dsolve[taylorseries]
References
Boyce, W.E., and DiPrima, R.C. Elementary Differential Equations and Boundary
Value Problems. 5th ed. New York: Wiley, 1992.
Conte, S.D., and C. de Boor. Elementary Numerical Analysis, An Algorithmic
Approach. McGraw-Hill, 1980.
28
Fox, L., and Mayers, D.F. Numerical Solution of Ordinary Differential Equations
for Scientists and Engineers. Chapman & Hall, 1987.
Lambert, J.D. Computational Methods in Ordinary Differential Equations. New
York: Wiley, 1973.
Calling Sequence
dsolve(odesys, numeric, method=rkf45, vars, options)
dsolve(numeric, method=rosenbrock, procopts, options)
Parameters
odesys
numeric
method=rkf45 -
vars
- (optional) any indeterminate function of one variable, or a set or list
of them, representing the unknowns of the ODE problem
options
Description
The dsolve command with the options numeric and method=rkf45 finds a numerical
solution using a Fehlberg fourth-fifth order Runge-Kutta method with degree four
interpolant. This is the default method of the type=numeric solution for initial value
problems when the stiff argument is not used.
Modes of Operation
The rkf45 method has two distinct modes of operation (for procedure-type outputs).
29
This method can be used in combination with the refine option of odeplot to produce
an adaptive plot (that is, odeplot uses the precomputed points to produce the plot
when refine is specified.)
It is not recommended that this method be used for problems in which the solution
can become singular, as each step is stored, and many steps may be taken when near a
singularity, so memory usage can become a significant issue.
The storage of the interpolant in use by this method can be disabled by using the
interpolation=false option described below. This is recommended for high accuracy
solutions where storage of the interpolant (in addition to the discrete solution)
requires too much memory. Disabling the interpolant is not generally recommended
because the solution values are obtained from an interpolation of the 5 closest points,
and does not necessarily provide an interpolant with order 4 error.
Without the range option
When used without the range option, the IVP solution values are not stored, but
rather computed when requested.
Because not all solution values are stored, computation must restart at the initial
values whenever a point is requested between the initial point and the most recently
computed point (to avoid reversal of the integration direction), so it is advisable to
collect solution values moving away from the initial value.
Options
keyword or array
'known'
'abserr'
numeric
'relerr'
numeric
'initstep'
numeric
'interr'
boolean
'maxfun'
integer
'number'
integer
'procedure'
procedure
'start'
numeric
'initial'
array
'procvars'
list
'startinit'
boolean
'implicit'
boolean
'optimize'
boolean
30
'compile'
boolean or 'auto'
'range'
numeric..numeric
'events'
list
'event_pre'
keyword
'event_maxiter' =
integer
'event_iterate' =
keyword
'event_initial' =
boolean
'complex'
boolean
output
Specifies the desired output from dsolve. The keywords procedurelist,
listprocedure, or operator provide procedure-type output, the keyword piecewise
provides output in the form of piecewise functions over a specified range of
independent variable values, and a 1-D array or Array provide output at fixed values
of the independent variable. For more information, see dsolve[numeric].
known
Specifies user-defined known functions. For more information, see dsolve[numeric].
abserr, relerr, and initstep
Specify the desired accuracy of the solution, and the starting step size for the method.
For more information, see dsolve[Error_Control]. The default values for rkf45 are
abserr = .1e-6 and relerr = .1e-5. The value for initstep, if not specified, is
determined by the method, taking into account the local behavior of the ODE system.
interr
By default this is set to true, and controls whether the solution interpolant error
(including the interpolant on index-1 variables for DAE problems) is integrated into
the error control. When set to false, areas where the solutions is varying rapidly (e.g.
a discontinuity in a derivative due to a piecewise) may have a much larger solution
error than dictated by the specified error tolerances. When set to true, the step size is
reduced to minimize error in these regions, but for problems where there is a jump
discontinuity in the variables, the integration may fail with an error indicating that a
singularity is present. In the latter case where an error is thrown, it may be
advantageous to model the discontinuities using events (see dsolve[Events]).
maxfun
Specifies a maximum on the number of evaluations of the right-hand side of the first
order ODE system. This option is disabled by specifying maxfun = 0. The default
value for rkf45 is 30000.
number, procedure, start, initial, and procvars
These options are used to specify the IVP using procedures. For more information,
see dsolve[numeric,IVP].
31
Additional Information
Examples
Solution with a range - solution over 0 .. 1 is stored:
> dsys1 := {diff(x(t),t)=y(t), diff(y(t),t)=x(t)+y(t),
x(0)=2, y(0)=1};
32
d
d
dsys1:= { x( t )y( t ), y( t )x( t )y( t ), x( 0 )2, y( 0 )1 }
dt
dt
> dsol2(0.4);
[ t0.4, x( t )2.69118458493342860
, y( t )2.60811748317278846
]
> dsol2(1.0);
[ t1.0, x( t )5.58216753140402577
, y( t )7.82688926499941395
]
array solution:
> dsys3 := {(D@@2)(x)(t)=-y(t), (D@@2)(y)(t)=D(x)(t)+y(t)};
( 2)
( 2)
33
dt
dt
[
[ 0. , 1. , 0. , 0. , 1. ]
[ 0.599999999999999978
, 0.963412011936564228
, -0.184806440812177813
,
0.631128387721555550
, 1.14821845274874179
]
[ 1.10000000000000009
, 0.766914770923161404
, -0.654359851893226097
,
1.26996581973442213
, 1.42127462281638772
]
[ 1.50000000000000000
, 0.387748428237649434
, -1.28270433657142369
,
1.88843381066575611
, 1.67045276480907257
]
[ 2.29999999999999982
, -1.39457660199567379
, -3.37272359631325491
,
3.37930993039341754
, 1.97814699431758090
]
[ 2.50000000000000000
, -2.13934166115934765
, -4.08805856231715214
,
3.77306761197420482
, 1.94871690115780605
]]
procedurelist output:
> deqn4 := { diff(y(t),t$3) - 2*diff(y(t),t$2) + 2*y(t) };
d3
d2
y
(
t
)
2
2 y( t ) 2 y( t ) }
dt3
dt
deqn4:= {
34
> dsol4(0.05);
d
, y( t )1.04995673867843053
,
t0.05, y( t )1.05124946305338263
dt
d2
2 y( t )0.997371821503983624
dt
> dsol4(-0.45);
d
, y( t )0.571757535785405224
,
t-0.45, y( t )0.648630782805870165
dt
d2
2 y( t )0.870897136753005841
dt
> eval(dsol5[2],t=0);
y( 0 )0.9999999997
0.4906666810-11 I
> eval(dsol5[2],t=evalf[15](Pi));
y( 3.14159265358979
)-1.000000643
0.238854434010-7 I
See Also
35
References
Enright, W.H.; Jackson, K.R.; Norsett, S.P.; and Thomsen, P.G. "Interpolants for
Runge-Kutta Formulas." ACM TOMS, Vol. 12. (1986): 193-218.
Fehlberg, E. "Klassische Runge-Kutta-Formeln vierter und niedrigerer Ordnung mit
Schrittweiten-Kontrolle und ihre Anwendung auf Waermeleitungsprobleme".
Computing. Vol. 6. (1970): 61-71.
Forsythe, G.E.; Malcolm, M.A.; and Moler, C.B. Computer Methods for
Mathematical Computations. New Jersey: Prentice Hall, 1977.
Shampine, L.F. and Corless, R.M. "Initial Value Problems for ODEs in Problem
Solving Environments". J. Comp. Appl. Math. Vol. 125(1-2). (2000): 31-40.
36