Navigation

Operators and Keywords

Function List:

C++ API

: [x, istate, msg] = lsode (fcn, x_0, t)
: [x, istate, msg] = lsode (fcn, x_0, t, t_crit)

Ordinary Differential Equation (ODE) solver.

The set of differential equations to solve is

dx
-- = f (x, t)
dt

with

x(t_0) = x_0

The solution is returned in the matrix x, with each row corresponding to an element of the vector t. The first element of t should be t_0 and should correspond to the initial state of the system x_0, so that the first row of the output is x_0.

The first argument, fcn, is a string, inline, or function handle that names the function f to call to compute the vector of right hand sides for the set of equations. The function must have the form

xdot = f (x, t)

in which xdot and x are vectors and t is a scalar.

If fcn is a two-element string array or a two-element cell array of strings, inline functions, or function handles, the first element names the function f described above, and the second element names a function to compute the Jacobian of f. The Jacobian function must have the form

jac = j (x, t)

in which jac is the matrix of partial derivatives

            |df_1  df_1       df_1 |
            |----  ----  ...  ---- |
            |dx_1  dx_2       dx_N |
            |                      |
            |df_2  df_2       df_2 |
            |----  ----  ...  ---- |
     df_i   |dx_1  dx_2       dx_N |
jac = ---- = |                      |
     dx_j   | .    .     .    .    |
            | .    .      .   .    |
            | .    .       .  .    |
            |                      |
            |df_N  df_N       df_N |
            |----  ----  ...  ---- |
            |dx_1  dx_2       dx_N |

The second and third arguments specify the initial state of the system, x_0, and the initial value of the independent variable t_0.

The fourth argument is optional, and may be used to specify a set of times that the ODE solver should not integrate past. It is useful for avoiding difficulties with singularities and points where there is a discontinuity in the derivative.

After a successful computation, the value of istate will be 2 (consistent with the Fortran version of LSODE).

If the computation is not successful, istate will be something other than 2 and msg will contain additional information.

You can use the function lsode_options to set optional parameters for lsode.

See also: daspk, dassl, dasrt.

Package: octave