Skip to content

__lsode__

builtin · libnexusinterp/corefcn/lsode-proprietary.cc

: [x, istate, msg] = __lsode__ (fcn, x0, t)
: [x, istate, msg] = __lsode__ (fcn, x0, t, t_crit)

Solve the initial value problem dx/dt = f (x, t), x(t0) = x0 for an ordinary differential equation system with the LSODE package.

Note the order of the arguments of f: the state comes first and the time second. The function returns a vector with the same number of elements as x0.

fcn is a function handle, the name of a function, or a cell array {f, jac} where jac returns the Jacobian matrix d f / d x for given x and t.

x0 is the initial state, and t lists the times at which the solution is wanted; its first element is the starting time and it must be monotonic (increasing or decreasing). Row k of the result x holds the state at t(k), so x has numel (t) rows and numel (x0) columns.

The optional t_crit lists times that the integrator must not step past, e.g. singular points.

On a successful run istate equals 2 and msg is "successful exit". A negative istate reports a failure; it raises an error unless istate is requested as an output.

Tolerances and the other solver settings are read and changed with lsode_options; the defaults make the stiff/non-stiff switching method use relative and absolute tolerances of about 1.5e-8.