The LSODE function uses adaptive numerical methods to advance a solution to a system of ordinary differential equations one time-step H, given values for the variables Y and X .

Calling Sequence

Result = LSODE( Y, X, H, Derivs[, Status] )



A vector of values for Y at X


A scalar value for the initial condition.


A scalar value giving interval length or step size.


A scalar string specifying the name of a user-supplied IDL function that calculates the values of the derivatives Dydx at X. This function must accept two arguments: A scalar floating value X , and one n-element vector Y . It must return an n -element vector result.

dy 0 / dx = -0.5 y 0,         dy 1 / dx = 4.0 - 0.3 y 1 - 0.1 y 0

We can write a function called differential to express these relationships in the IDL language:

FUNCTION differential, X, Y

RETURN, [-0.5 * Y[0], 4.0 - 0.3 * Y[1] - 0.1 * Y[0]]



An index used for input and output to specify the state of the calculation. This argument contains a positive value if the function was successfully completed. Negative values indicate different errors.

  • Input Values for Status

Input Value



This is the first call for the problem; initializations will occur. This is the default value.


This is not the first call. The calculation is to continue normally.


This is not the first call. The calculation is to continue normally, but with a change in input parameters.


To integrate the example system of differential equations for one time step, H:

H = 0.5; Define the step size.

X = 0.0; Define an initial X value.

Y = [4.0, 6.0]; Define initial Y values.

result = LSODE(Y, X, H, 'differential')
; Integrate over the interval (0, 0.5).

PRINT, result; Print the result.

IDL prints:

3.11523             6.85767

This is the exact solution vector to 5-decimal precision.

See Also



  1. Alan C. Hindmarsh, ODEPACK, A Systematized Collection of ODE Solvers, in Scientific Computing, R. S. Stepleman et al. (eds.), North-Holland, Amsterdam, 1983,
    pp. 55-64.
  2. Linda R. Petzold, Automatic Selection of Methods for Solving Stiff and Nonstiff Systems of Ordinary Differential Equations, SIAM J. SCI. STAT. COMPUT. 4 (1983), pp. 136-148.
  3. Kathie L. Hiebert and Lawrence F. Shampine, Implicitly Defined Output Points for Solutions of ODE's, Sandia Report SAND80-0180, February, 1980.