numerical solution of ordinary differential equations

 Calling Sequence dsolve(odesys, numeric, method=lsode, options) dsolve(odesys, numeric, method=lsode[choice], vars, options) dsolve(numeric, method=lsode[choice], vars, options)

Parameters

 odesys - set or list; ordinary differential equation(s) and initial conditions numeric - literal name; instruct dsolve to find a numerical solution method=lsode - literal equation; numerical method to use method=lsode[choice] - literal 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

Description

 • This page describes the advanced use form of the lsode method for the numerical solution of ODE initial value problems. The general usage of this method, including the choice of the sub-method, is described in dsolve[lsode].
 • The advanced use optional equations for method=lsode are as follows:

 'itask' = integer 'ctrl' = array

 • The itask parameter is an integer index specifying the type of task to be performed. It can have the following values:

 Value Meaning $1$ normal computation of output values of $y\left(t\right)$ (by overshooting the endpoint and interpolating) $2$ take one step only and return $3$ stop at the first internal mesh point at or beyond the endpoint and return $4$ normal computation of output values of $y\left(t\right)$ at the endpoint without overshooting tcrit (tcrit is the critical time value that integration should not pass; it can be equal to or beyond the endpoint, but must not be behind the endpoint in the direction of integration) $5$ means take one step without passing tcrit and return

 The default value is $1$.
 • The ctrl parameter c is a vector of floating-point numbers and integers with length at least $21+\mathrm{neqns}$ (where $\mathrm{neqns}$ is the number of equations in the system to be considered). The  first $11$ values are optional inputs, and the remaining positions are reserved for optional output values. The correspondence of meanings and individual vector elements is as follows:
 Inputs:
 • ${c}_{1}=\mathrm{rtol}$ where rtol is a relative error tolerance parameter.  The default value is Float(1,-7).
 • ${c}_{2}=\mathrm{atol}$ where atol is an absolute error tolerance parameter.  The values of atol and rtol determine the error control performed by the solver. The solver will control a vector $e\left(i\right)$ of estimated local errors in y according to an inequality of the form rms-norm of $\frac{e\left(i\right)}{\mathrm{ewt}\left(i\right)}\le 1$, where $\mathrm{ewt}\left(i\right)=\mathrm{rtol}\left|y\left(i\right)\right|+\mathrm{atol}$  and rms-norm is the root-mean-square norm.  Use $\mathrm{rtol}=0$ for absolute error checking, and $\mathrm{atol}=0$ for relative error checking.  The default for atol is Float(1,-7).
 • ${c}_{3}=\mathrm{tcrit}$ where tcrit is the critical independent variable value which must not be passed (only used for itask = 4 or 5). Its default value is $\mathrm{x0}+0.1$.
 • ${c}_{4}=\mathrm{\mu }$ where mu is the upper half-bandwidth required for banded Jacobian methods excluding the main diagonal.
 • ${c}_{5}=\mathrm{ml}$ where ml is the lower half-bandwidth required for banded Jacobian methods excluding the main diagonal.  The band is defined by the matrix locations: for row i and column j with $i-\mathrm{ml}<=j<=i+\mathrm{mu}$.  ml and mu must satisfy $0\le \mathrm{ml}$, $\mathrm{\mu }\le \mathrm{neqns}-1$.
 • ${c}_{6}=\mathrm{h0}$ where h0 is the step size to attempt on the first step. If h0 is not specified, the default value is determined by the solver.
 • ${c}_{7}=\mathrm{hmax}$ where hmax is the maximum absolute step size allowed. The default value is infinite.
 • ${c}_{8}=\mathrm{hmin}$ where hmin is the minimum absolute step size allowed. The default value is zero (Note: This lower bound is not enforced on the final step before reaching tcrit on $\mathrm{itask}=4$ or $5$).
 • ${c}_{9}=\mathrm{maxord}$ where maxord is the maximum order to be allowed. The default value is $12$ for Adams methods and $5$ for backward differentiation. If maxord exceeds these defaults, it will be reduced to the appropriate value.
 • ${c}_{10}=\mathrm{mxstep}$ where mxstep is the maximum number of (internally defined) steps allowed during one call to the solver.  The default value is $500$.
 • ${c}_{11}=\mathrm{mxhnil}$ where mxhnil is the maximum number of error conditions of $t+h=t$ of a step. The default value is $10$.
 Outputs:
 • ${c}_{12}=\mathrm{istate}$ where istate can have the following values on output:

 Value Meaning $1$ nothing was done as tout was equal to t on input $2$ the integration was performed successfully $-1$ an excessive amount of work (more than mxstep steps) was done during the call  before completing the requested task $-2$ too much accuracy was requested for the precision of the machine being used $-3$ illegal input was detected  before taking any steps $-4$ there was repeated error test failures on one attempted step (the problem may have a singularity) $-5$ there were repeated convergence test failures on one attempted step (this may be caused by an inaccurate Jacobian matrix  if being used) $-6$ indicates $\mathrm{ewt}\left(i\right)$ became zero for some i during the integration (i.e., pure absolute error control was requested on a variable that has now vanished)

 • ${c}_{13}=\mathrm{hu}$ where hu is the step size in t last used.
 • ${c}_{14}=\mathrm{hcur}$ where hcur is the step size that was to be attempted on the next step.
 • ${c}_{15}=\mathrm{tcur}$ where tcur is the current value of the independent variable which the solver has actually reached (i.e., the current internal mesh point in $t$).  At output  tcur will always be at least as far as the argument, t, but may be farther (if interpolation was done).
 • ${c}_{16}=\mathrm{tolsf}$ where tolsf is a tolerance scale factor greater than $1.0$, computed when a request for too much accuracy was detected ($\mathrm{istate}=-3$ or $-2$).  If $\mathrm{rtol}$ and atol are scaled up by a factor of tolsf for another call, then the solver is deemed likely to succeed.
 • ${c}_{17}=\mathrm{nst}$ where nst is the number of steps taken for the problem so far.
 • ${c}_{18}=\mathrm{nfe}$ where nfe is the number of function (differential system) evaluations for the problem so far.
 • ${c}_{19}=\mathrm{nje}$ where nje is the number of Jacobian evaluations for the problem so far.
 • ${c}_{20}=\mathrm{nqu}$ where nqu is the method order last used (successfully).
 • ${c}_{21}=\mathrm{nqcur}$ where nqcur is the order that was to be attempted on the next step.
 • ${c}_{22..21+\mathrm{neqns}}={\mathrm{acor}}_{1..\mathrm{neqns}}$ where acor is an array of size neqns used for the accumulated corrections on each step scaled on output to represent the estimated local error in y on the last step.  It is defined only on a successful return from lsode.

Examples

 > $C≔\mathrm{array}\left(\left[\mathrm{}\left(0,26\right)\right]\right):$
 > $C\left[3\right]≔0.75:$
 > $C\left[4\right]≔1:$
 > $C\left[5\right]≔1:$
 > $C\left[10\right]≔2500:$
 > $\mathrm{deq1}≔\mathrm{diff}\left(v\left(t\right),\mathrm{}\left(t,5\right)\right)-\mathrm{diff}\left(v\left(t\right),\mathrm{}\left(t,2\right)\right)=v\left(t\right)-t$
 ${\mathrm{deq1}}{≔}\frac{{{ⅆ}}^{{5}}}{{ⅆ}{{t}}^{{5}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){-}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){=}{v}{}\left({t}\right){-}{t}$ (1)
 > $\mathrm{init1}≔v\left(0\right)=0.25,\mathrm{D}\left(v\right)\left(0\right)=0.75,{\mathrm{D}}^{\left(2\right)}\left(v\right)\left(0\right)=1,{\mathrm{D}}^{\left(3\right)}\left(v\right)\left(0\right)=0,{\mathrm{D}}^{\left(4\right)}\left(v\right)\left(0\right)=-0.25$
 ${\mathrm{init1}}{≔}{v}{}\left({0}\right){=}{0.25}{,}{\mathrm{D}}{}\left({v}\right){}\left({0}\right){=}{0.75}{,}{{\mathrm{D}}}^{\left({2}\right)}{}\left({v}\right){}\left({0}\right){=}{1}{,}{{\mathrm{D}}}^{\left({3}\right)}{}\left({v}\right){}\left({0}\right){=}{0}{,}{{\mathrm{D}}}^{\left({4}\right)}{}\left({v}\right){}\left({0}\right){=}{-0.25}$ (2)
 > $\mathrm{ans1}≔\mathrm{dsolve}\left(\left\{\mathrm{deq1},\mathrm{init1}\right\},\mathrm{numeric},\mathrm{method}=\mathrm{lsode}\left[\mathrm{backband}\right],\mathrm{ctrl}=C\right):$
 > $\mathrm{ans1}\left(0.65\right)$
 $\left[{t}{=}{0.65}{,}{v}{}\left({t}\right){=}{0.948081855882857}{,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){=}{1.39770380574707}{,}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){=}{1.00339524678793}{,}\frac{{{ⅆ}}^{{3}}}{{ⅆ}{{t}}^{{3}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){=}{0.0968760633151896}{,}\frac{{{ⅆ}}^{{4}}}{{ⅆ}{{t}}^{{4}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({t}\right){=}{0.553051343710615}\right]$ (3)