dsolve/numeric/classical
numerical solution of ordinary differential equations
Calling Sequence
Parameters
Description
Examples
References
dsolve(odesys, numeric, method=classical)
dsolve(odesys, numeric, method=classical[choice], vars, options)
dsolve(numeric, method=classical[choice], procopts, options)
odesys
-
set or list; ordinary differential equation(s) and initial conditions
numeric
literal name; instruct dsolve to find a numerical solution
method=classical
literal equation; numerical method to use
method=classical[choice]
equation; numerical method and submethod to use
vars
(optional) dependent variable or a set or list of dependent variables for odesys
options
(optional) equations of the form keyword = value
procopts
options used to specify the ODE system using a procedure (procedure, initial, start, number, and procvars). For more information, see dsolve[numeric,IVP].
The dsolve command with the options numeric and method=classical or method=classical[choice] finds a numerical solution by using one of the classical numerical methods as described in the following.
These methods use a fixed step size, provide no error estimation or correction, and are provided primarily for educational purposes. If practical numerical solution of ODE initial value problems (IVP) is required, it is suggested that any of the other methods mentioned in dsolve[numeric,IVP] help page be used instead.
A number of classical methods are available through use of the choice option in the method=classical[choice] selection. The default is foreuler, the forward Euler method.
The available choices of the classical method are described for the problem y'⁢=f⁡t,y, where Yi is the estimated value of the solution at the time ti, h is the fixed step size ti−ti−1, and for each formula the value of the solution Yn+1 at time tn+1 is being computed.
foreuler is the forward Euler method specified by the equation:
Yn+1=Yn+h⁢f⁡tn,Yn
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=Yn+h⁢f⁡tn,Yn
Yn+1=Yn+h⁢f⁡tn,Yn+f⁡tn+1,Yp2
impoly is the improved polygon method (also known as the modified Euler method), as specified by the equation:
Yn+1=Yn+h⁢f⁡tn+h2,Yn+h⁢f⁡tn,Yn2
rk2 is the second-order classical Runge-Kutta method, as specified by:
k1=f⁡tn,Yn
k2=f⁡tn+h,h⁢k1+Yn
Yn+1=Yn+h⁢k1+k22
Note: This is the same as the Heun formula.
rk3 is the third-order classical Runge-Kutta method, as specified by:
k2=f⁡tn+h2,Yn+h⁢k12
k3=f⁡tn+h,Yn+h⁢−k1+2⁢k2
Yn+1=Yn+h⁢k1+4⁢k2+k36
rk4 is the fourth-order classical Runge-Kutta method, as specified by:
k3=f⁡tn+h2,Yn+h⁢k22
k4=f⁡tn+h,h⁢k3+Yn
Yn+1=Yn+h⁢k1+2⁢k2+2⁢k3+k46
This is not to be confused with method=rkf45, which uses a Fehlberg fourth-fifth order Runge-Kutta method.
adambash is the Adams-Bashforth method (a predictor method), as specified by:
Yn+1=Yn+h⁢55⁢f⁡tn,Yn−59⁢f⁡tn−1,Yn−1+37⁢f⁡tn−2,Yn−2−9⁢f⁡tn−3,Yn−324
abmoulton is the Adams-Bashforth-Moulton method (a predictor-corrector method), as specified by:
Yn+1=Yn+h⁢9⁢f⁡tn+1,Yn+1+19⁢f⁡tn,Yn−5⁢f⁡tn−1,Yn−1+f⁡tn−2,Yn−224,
where f⁡tn+1,Yn+1 is found by first applying the Adams-Bashforth method (the predictor), then using the above Adams-Bashforth-Moulton method (the corrector).
Note that both adambash and abmoulton are multipoint methods that require the initial condition and three other equally spaced starting values. These starting values are obtained by computing the first 3 steps using the rk4 method. In addition, since fixed spacing is required for use of these methods, the final step used in obtaining requested solution values also uses the rk4 method (as there is no guarantee that solution values will only be requested at exact multiples of the step size).
The following options are available for the classical method:
'output'
=
keyword or array
'known'
name or list of names
'maxfun'
integer
'number'
'procedure'
procedure
'start'
'initial'
array
'procvars'
list
'startinit'
boolean
'implicit'
'optimize'
'stepsize'
'corrections'
Specifies the desired output from dsolve, and the known option specifies user-defined known functions. For more information, see dsolve[numeric].
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].
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⁡Tf3−T03,0.005 for forward integration and h=max⁡Tf3−T03,−0.005 for backward integration, respectively, where the problem is solved over the interval from T0 to Tf.
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.
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≔ⅆ3ⅆt3y⁡t=y⁡t+ⅆⅆtx⁡t,ⅆ2ⅆt2x⁡t=x⁡t⁢y⁡t−ⅆ2ⅆt2y⁡t
init1≔y⁡0=1,D⁡y⁡0=2,D2⁡y⁡0=−1,x⁡0=4,D⁡x⁡0=4.3
ans1≔dsolve⁡dsys1,init1,numeric,method=classicalabmoulton,corrections=2
ans1 ≔ procx_classical...end proc
ans1⁡1.0
t=1.0,x⁡t=13.1246093792716,ⅆⅆtx⁡t=18.7876915350014,y⁡t=3.76283413230601,ⅆⅆty⁡t=5.31760397608216,ⅆ2ⅆt2y⁡t=10.2504683623596
deq2≔diff⁡y⁡x,`$`⁡x,2=y⁡x
deq2≔ⅆ2ⅆx2y⁡x=y⁡x
init2≔y⁡0=1,D⁡y⁡0=1
Digits≔20:
ans2≔dsolve⁡deq2,init2,numeric,method=classicalheunform,output=Array⁡0.01,0.1,1,stepsize=0.001
ans2≔xy⁡xⅆⅆxy⁡x0.011.01005016540201317151.01005016540201317150.11.10517089966994158801.10517089966994158801.2.71828137575176083992.7182813757517608399
Digits≔10:
deq3≔diff⁡y⁡t,`$`⁡t,4−diff⁡y⁡t,`$`⁡t,3=y⁡t⁢t2
deq3≔ⅆ4ⅆt4y⁡t−ⅆ3ⅆt3y⁡t=y⁡t⁢t2
init3≔y⁡0=3.56,D⁡y⁡0=12,D2⁡y⁡0=−4,D3⁡y⁡0=6.544
ans3≔dsolve⁡deq3unioninit3,numeric,method=classicalrk3,output=listprocedure:
sol3≔eval⁡y⁡t,ans3
sol3 ≔ proct...end proc
sol3⁡0
3.56
sol3⁡0.56
9.87504792480695
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.
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.
See Also
dsolve[ck45]
dsolve[dverk78]
dsolve[gear]
dsolve[lsode]
dsolve[maxfun]
dsolve[numeric,IVP]
dsolve[numeric]
dsolve[rkf45]
dsolve[rosenbrock]
dsolve[taylorseries]
plots[odeplot]
Download Help Document