dsolve/numeric/rkf45 - Maple Programming Help

Home : Support : Online Help : Mathematics : Differential Equations : dsolve : numeric : Methods : dsolve/rkf45

dsolve/numeric/rkf45

find numerical solution of ordinary differential equations

 Calling Sequence dsolve($\mathrm{odesys}$, numeric, method=rkf45, vars, options) dsolve(numeric, method=rkf45, procopts, options)

Parameters

 odesys - set or list; ordinary differential equation(s) and initial conditions numeric - literal name; instruct dsolve to find a numerical solution method=rkf45 - literal equation; numerical method to use vars - (optional) any indeterminate function of one variable, or a set or list of them, representing the unknowns of the ODE problem 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.

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.  The other non-stiff method is a Runge-Kutta method with the Cash-Karp coefficients, ck45.

Modes of Operation

 • The rkf45 method has two distinct modes of operation (for procedure-type outputs).
 • With the range option
 When used with the range option, the method computes the solution for the IVP over the specified range, storing the solution information internally, and uses that information to rapidly interpolate the desired solution value for any call to the returned procedure(s).
 Though possible, it is not recommended that the returned procedure be called for points outside the specified range.
 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

 • The following options are available for the rkf45 method.

 'output' = keyword or array 'known' = name or list of names '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 '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
 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-7 and relerr=1e-6. 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 $\mathrm{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 $\mathrm{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 $\mathrm{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.
 startinit, implicit, and optimize
 These options control the method and behavior of the computation. For more information on startinit and implicit, see dsolve/numeric/IVP. For more information on optimize, see dsolve/numeric.
 compile
 This option specifies that the internally generated procedures that are used to compute the numeric solution be compiled for efficiency. Note that this option will only work if $\mathrm{Digits}$ is set within the hardware precision range, and the input function contains only evalhf capable functions (e.g. only elementary mathematical functions like exp, sin, and ln).  See dsolve/Efficiency. By default this value is set to false. If set to true and a compile is not possible, an error will be thrown. If set to auto and a compile is not possible, the uncompiled procedures will be used directly.
 range
 Determines the range of values of the independent variable for which solution values are required. Use of this option significantly changes the behavior of the method for the procedure-style output types discussed in dsolve/numeric (see description of with/without range in Modes of Operation section of this help page).
 events, event_pre, event_maxiter, event_iterate, event_initial
 These options are used to specify and control the behavior of events for the numerical solution. These options are discussed in detail in dsolve/Events.
 complex
 Accepts a boolean value indicating if the problem is (or will become) complex valued. By default this is detected based on the input system and initial data, but in cases where the input system is procedure defined, or the system is initially real, it may be necessary to specify complex=true to obtain the solution. It is assumed that for an initially real system that becomes complex, the point at which this transition occurs is considered to be a singularity, so if complex=true is not specified, the integration will halt at that point.

 • By setting infolevel[dsolve] to $2$, information on the last mesh point evaluation is provided in the event of an error.
 • The rkf45 method is capable of computing high-accuracy solutions for IVPs because the precision of the computation can be increased by changing the Digits environment variable. However, it is recommended that the higher order dverk78 or gear methods be used instead.
 • Results can be plotted by using the function odeplot in the plots package.

Examples

Solution with a range - solution over $0..1$ is stored:

 > $\mathrm{dsys1}≔\left\{\frac{ⅆ}{ⅆt}x\left(t\right)=y\left(t\right),\frac{ⅆ}{ⅆt}y\left(t\right)=x\left(t\right)+y\left(t\right),x\left(0\right)=2,y\left(0\right)=1\right\}$
 ${\mathrm{dsys1}}{≔}\left\{\frac{{ⅆ}}{{ⅆ}{t}}{}{x}{}\left({t}\right){=}{y}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}{}{y}{}\left({t}\right){=}{x}{}\left({t}\right){+}{y}{}\left({t}\right){,}{x}{}\left({0}\right){=}{2}{,}{y}{}\left({0}\right){=}{1}\right\}$ (1)
 > $\mathrm{dsol1}≔\mathrm{dsolve}\left(\mathrm{dsys1},\mathrm{numeric},\mathrm{output}=\mathrm{listprocedure},\mathrm{range}=0..1\right):$
 > $\mathrm{dsol1x}≔\mathrm{subs}\left(\mathrm{dsol1},x\left(t\right)\right):$$\mathrm{dsol1y}≔\mathrm{subs}\left(\mathrm{dsol1},y\left(t\right)\right):$
 > $\left[\mathrm{dsol1x}\left(0\right),\mathrm{dsol1y}\left(0\right)\right]$
 $\left[{2.}{,}{1.}\right]$ (2)
 > $\left[\mathrm{dsol1x}\left(0.4\right),\mathrm{dsol1y}\left(0.4\right)\right]$
 $\left[{2.69118458493332}{,}{2.60811748317261}\right]$ (3)
 > $\left[\mathrm{dsol1x}\left(1.0\right),\mathrm{dsol1y}\left(1.0\right)\right]$
 $\left[{5.58216753140384}{,}{7.82688926499912}\right]$ (4)

Solution without a range - each point is computed when requested:

 > $\mathrm{dsol2}≔\mathrm{dsolve}\left(\mathrm{dsys1},\mathrm{numeric},\mathrm{method}=\mathrm{rkf45},\mathrm{output}=\mathrm{procedurelist}\right):$
 > $\mathrm{dsol2}\left(0\right)$
 $\left[{t}{=}{0.}{,}{x}{}\left({t}\right){=}{2.}{,}{y}{}\left({t}\right){=}{1.}\right]$ (5)
 > $\mathrm{dsol2}\left(0.4\right)$
 $\left[{t}{=}{0.4}{,}{x}{}\left({t}\right){=}{2.69118458493332}{,}{y}{}\left({t}\right){=}{2.60811748317261}\right]$ (6)
 > $\mathrm{dsol2}\left(1.0\right)$
 $\left[{t}{=}{1.0}{,}{x}{}\left({t}\right){=}{5.58216753140384}{,}{y}{}\left({t}\right){=}{7.82688926499911}\right]$ (7)

array solution:

 > $\mathrm{dsys3}≔\left\{{\mathrm{D}}^{\left(2\right)}\left(x\right)\left(t\right)=-y\left(t\right),{\mathrm{D}}^{\left(2\right)}\left(y\right)\left(t\right)=\mathrm{D}\left(x\right)\left(t\right)+y\left(t\right)\right\}$
 ${\mathrm{dsys3}}{≔}\left\{{{\mathrm{D}}}^{\left({2}\right)}{}\left({x}\right){}\left({t}\right){=}{-}{y}{}\left({t}\right){,}{{\mathrm{D}}}^{\left({2}\right)}{}\left({y}\right){}\left({t}\right){=}{\mathrm{D}}{}\left({x}\right){}\left({t}\right){+}{y}{}\left({t}\right)\right\}$ (8)
 > $\mathrm{init3}≔\left\{x\left(0\right)=1,\mathrm{D}\left(x\right)\left(0\right)=0,y\left(0\right)=0,\mathrm{D}\left(y\right)\left(0\right)=1\right\}$
 ${\mathrm{init3}}{≔}\left\{{x}{}\left({0}\right){=}{1}{,}{y}{}\left({0}\right){=}{0}{,}{\mathrm{D}}{}\left({x}\right){}\left({0}\right){=}{0}{,}{\mathrm{D}}{}\left({y}\right){}\left({0}\right){=}{1}\right\}$ (9)
 > $\mathrm{dsol3}≔\mathrm{dsolve}\left(\mathrm{dsys3}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∪\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{init3},\mathrm{numeric},\mathrm{method}=\mathrm{rkf45},\mathrm{output}=\mathrm{Array}\left(\left[0,0.6,1.1,1.5,2.3,2.5\right]\right)\right)$
 ${\mathrm{dsol3}}{≔}\left[\begin{array}{c}\left[\begin{array}{ccccc}{t}& {x}{}\left({t}\right)& \frac{{ⅆ}}{{ⅆ}{t}}{}{x}{}\left({t}\right)& {y}{}\left({t}\right)& \frac{{ⅆ}}{{ⅆ}{t}}{}{y}{}\left({t}\right)\end{array}\right]\\ \left[\begin{array}{ccccc}{0.}& {1.}& {0.}& {0.}& {1.}\\ {0.600000000000000}& {0.963412011936559}& {-}{0.184806440812173}& {0.631128387721561}& {1.14821845274873}\\ {1.10000000000000}& {0.766914770923156}& {-}{0.654359851893226}& {1.26996581973443}& {1.42127462281638}\\ {1.50000000000000}& {0.387748428237642}& {-}{1.28270433657147}& {1.88843381066579}& {1.67045276480911}\\ {2.30000000000000}& {-}{1.39457660199566}& {-}{3.37272359631323}& {3.37930993039341}& {1.97814699431758}\\ {2.50000000000000}& {-}{2.13934166115931}& {-}{4.08805856231711}& {3.77306761197417}& {1.94871690115780}\end{array}\right]\end{array}\right]$ (10)

procedurelist output:

 > $\mathrm{deqn4}≔\left\{\frac{{ⅆ}^{3}}{ⅆ{t}^{3}}y\left(t\right)-2\left(\frac{{ⅆ}^{2}}{ⅆ{t}^{2}}y\left(t\right)\right)+2y\left(t\right)\right\}$
 ${\mathrm{deqn4}}{≔}\left\{\frac{{{ⅆ}}^{{3}}}{{ⅆ}{{t}}^{{3}}}{}{y}{}\left({t}\right){-}{2}{}\left(\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}{}{y}{}\left({t}\right)\right){+}{2}{}{y}{}\left({t}\right)\right\}$ (11)
 > $\mathrm{init4}≔\left\{y\left(0\right)=1,\mathrm{D}\left(y\right)\left(0\right)=1,{\mathrm{D}}^{\left(2\right)}\left(y\right)\left(0\right)=1\right\}$
 ${\mathrm{init4}}{≔}\left\{{y}{}\left({0}\right){=}{1}{,}{\mathrm{D}}{}\left({y}\right){}\left({0}\right){=}{1}{,}{{\mathrm{D}}}^{\left({2}\right)}{}\left({y}\right){}\left({0}\right){=}{1}\right\}$ (12)
 > $\mathrm{dsol4}≔\mathrm{dsolve}\left(\mathrm{deqn4}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∪\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{init4},\mathrm{numeric},\mathrm{method}=\mathrm{rkf45},\mathrm{relerr}=1.{10}^{-8},\mathrm{abserr}=1.{10}^{-8},\mathrm{maxfun}=0,\mathrm{output}=\mathrm{procedurelist}\right)$
 ${\mathrm{dsol4}}{≔}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (13)
 > $\mathrm{dsol4}\left(0.05\right)$
 $\left[{t}{=}{0.05}{,}{y}{}\left({t}\right){=}{1.05124946305338}{,}\frac{{ⅆ}}{{ⅆ}{t}}{}{y}{}\left({t}\right){=}{1.04995673867843}{,}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}{}{y}{}\left({t}\right){=}{0.997371821503983}\right]$ (14)
 > $\mathrm{dsol4}\left(-0.45\right)$
 $\left[{t}{=}{-}{0.45}{,}{y}{}\left({t}\right){=}{0.648630782805870}{,}\frac{{ⅆ}}{{ⅆ}{t}}{}{y}{}\left({t}\right){=}{0.571757535785405}{,}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}{}{y}{}\left({t}\right){=}{0.870897136753006}\right]$ (15)

Piecewise output for complex-valued problem:

 > $\mathrm{deqn5}≔\left\{\frac{ⅆ}{ⅆt}y\left(t\right)=Iy\left(t\right)\right\}$
 ${\mathrm{deqn5}}{≔}\left\{\frac{{ⅆ}}{{ⅆ}{t}}{}{y}{}\left({t}\right){=}{I}{}{y}{}\left({t}\right)\right\}$ (16)
 > $\mathrm{init5}≔\left\{y\left(0\right)=1\right\}$
 ${\mathrm{init5}}{≔}\left\{{y}{}\left({0}\right){=}{1}\right\}$ (17)
 > $\mathrm{dsol5}≔\mathrm{dsolve}\left(\mathrm{deqn5}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∪\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{init5},\mathrm{numeric},\mathrm{method}=\mathrm{rkf45},\mathrm{output}=\mathrm{piecewise},\mathrm{complex}=\mathrm{true},\mathrm{range}=0..\mathrm{π}\right):$
 > $\mathrm{length}\left(\mathrm{dsol5}\right)$
 ${7753}$ (18)
 > $\genfrac{}{}{0}{}{{\mathrm{dsol5}}_{2}}{\phantom{t=0}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{{\mathrm{dsol5}}_{2}}}{t=0}$
 ${y}{}\left({0}\right){=}{0.9999999997}{+}{4.9066668}{}{{10}}^{{-12}}{}{I}$ (19)
 > $\genfrac{}{}{0}{}{{\mathrm{dsol5}}_{2}}{\phantom{t=\mathrm{evalf}[15]\left(\mathrm{π}\right)}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{{\mathrm{dsol5}}_{2}}}{t=\mathrm{evalf}[15]\left(\mathrm{π}\right)}$
 ${y}{}\left({3.14159265358979}\right){=}{-}{1.000000643}{+}{2.430759107}{}{{10}}^{{-8}}{}{I}$ (20)

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.