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 .
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:
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.
NOTE:
A preliminary call with
tout = t
is not counted as a first call here, as no initialization or checking of input is done. (Such a call is sometimes useful for the purpose of outputting the initial condition
s
.) Thus, the first call for which tout
t requires
STATUS = 1
on input..
NOTE: Since the normal output value of STATUS is 2, it does not need to be reset for normal continuation. Also, since a negative input value of STATUS will be regarded as illegal, a negative output value requires the user to change it, and possibly other inputs, before calling the solver again.
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).