numerical solution of ordinary differential equations
dsolve(odesys, numeric, method=classical)
dsolve(odesys, numeric, method=classical[choice], vars, options)
dsolve(numeric, method=classical[choice], procopts, options)
set or list; ordinary differential equation(s) and initial conditions
literal name; instruct dsolve to find a numerical solution
literal equation; numerical method to use
equation; numerical method and submethod to use
(optional) dependent variable or a set or list of dependent variables for odesys
(optional) equations of the form keyword = value
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:
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:
impoly is the improved polygon method (also known as the modified Euler method), as specified by the equation:
rk2 is the second-order classical Runge-Kutta method, as specified by:
Note: This is the same as the Heun formula.
rk3 is the third-order classical Runge-Kutta method, as specified by:
rk4 is the fourth-order classical Runge-Kutta method, as specified by:
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:
abmoulton is the Adams-Bashforth-Moulton method (a predictor-corrector method), as specified by:
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:
keyword or array
name or list of names
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⁡T03−Tf3,0.005 for forward integration and h=max⁡T03−Tf3,−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 ≔ ⅆ3ⅆt3⁢y⁡t=y⁡t+ⅆⅆt⁢x⁡t,ⅆ2ⅆt2⁢x⁡t=x⁡t⁢y⁡t−ⅆ2ⅆt2⁢y⁡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
deq2 ≔ ⅆ2ⅆx2⁢y⁡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
Digits ≔ 10:
deq3 ≔ ⅆ4ⅆt4⁢y⁡t−ⅆ3ⅆt3⁢y⁡t=y⁡t⁢t2
init3 ≔ y⁡0=3.56,D⁡y⁡0=12,D2⁡y⁡0=−4,D3⁡y⁡0=6.544
ans3 ≔ dsolve⁡deq3∪init3,numeric,method=classicalrk3,output=listprocedure:
sol3 ≔ eval⁡y⁡t,ans3
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.
Download Help Document
What kind of issue would you like to report? (Optional)