Imsl Rkta
Imsl Rkta
Imsl Rkta
0 5 ′
− pu ′ + qu = λru,
Sturm-Liouville problems SLEIG
page 745
α u0 a5 − α 1 pu ′0 a56
1 2
= λ2α ′ u0 a5 − α ′ 1 pu ′0 a567
1 2
β u0 b5 + β 1 pu ′0 b56 = 0
1 2
Usage
CALL IVPRK (IDO, N, FCN, T, TEND, TOL, PARAM, Y)
Arguments
IDO — Flag indicating the state of the computation. (Input/Output)
IDO State
1 Initial entry
2 Normal re-entry
3 Final call to release workspace
4 Return because of interrupt 1
5 Return because of interrupt 2 with step accepted
6 Return because of interrupt 2 with step rejected
Normally, the initial call is made with IDO = 1. The routine then sets IDO = 2,
and this value is used for all but the last call that is made with IDO = 3. This final
call is used to release workspace, which was automatically allocated by the initial
call with IDO = 1. No integration is performed on this final call. See Comment 3
for a description of the other interrupts.
N — Number of differential equations. (Input)
FCN — User-supplied SUBROUTINE to evaluate functions. The usage is CALL
FCN (N, T, Y, YPRIME), where
N – Number of equations. (Input)
T – Independent variable, t. (Input)
Y – Array of size N containing the dependent variable values, y.
(Input)
YPRIME – Array of size N containing the values of the vector y′
evaluated at (t, y). (Output)
FCN must be declared EXTERNAL in the calling program.
T — Independent variable. (Input/Output)
On input, T contains the initial value. On output, T is replaced by TEND unless
error conditions have occurred. See IDO for details.
Comments
1. Automatic workspace usage is
IVPRK 10N units, or
DIVPRK 20N units.
Workspace may be explicitly provided, if desired, by use of
I2PRK/DI2PRK. The reference is
CALL I2PRK (IDO, N, FCN, T, TEND, TOL, PARAM, Y,
VNORM, WK)
The additional arguments are as follows:
Algorithm
Routine IVPRK finds an approximation to the solution of a system of first-order
differential equations of the form y0 = f (t, y) with given initial data. The routine
attempts to keep the global error proportional to a user-specified tolerance. This
routine is efficient for nonstiff systems where the derivative evaluations are not
expensive.
Example 1
Consider a predator-prey problem with rabbits and foxes. Let r be the density of
rabbits and let f be the density of foxes. In the absence of any predator-prey
interaction, the rabbits would increase at a rate proportional to their number, and
the foxes would die of starvation at a rate proportional to their number.
Mathematically,
r ′ = 2r
f′=−f
The rate at which the rabbits are eaten by the foxes is 2r f, and the rate at which
the foxes increase, because they are eating the rabbits, is r f. So, the model to be
solved is
r ′ = 2r − 2r f
f′=−f+rf
The initial conditions are r(0) = 1 and f(0) = 3 over the interval 0 ≤ t ≤ 10.
In the program Y(1) = r and Y(2) = f. Note that the parameter vector PARAM is first
set to zero with IMSL routine SSET (page 1037). Then, absolute error control is
selected by setting PARAM(10) = 1.0.
The last call to IVPRK with IDO = 3 deallocates IMSL workspace allocated on the
first call to IVPRK. It is not necessary to release the workspace in this example
because the program ends after solving a single problem. The call to release
workspace is made as a model of what would be needed if the program included
further calls to IMSL routines.
INTEGER MXPARM, N
PARAMETER (MXPARM=50, N=2)
C SPECIFICATIONS FOR LOCAL VARIABLES
INTEGER IDO, ISTEP, NOUT
REAL PARAM(MXPARM), T, TEND, TOL, Y(N)
C SPECIFICATIONS FOR SUBROUTINES
EXTERNAL IVPRK, SSET, UMACH, FCN
C
CALL UMACH (2, NOUT)
C Set initial conditions
T = 0.0
Y(1) = 1.0
Y(2) = 3.0
C Set error tolerance
TOL = 0.0005
C Set PARAM to default
CALL SSET (MXPARM, 0.0, PARAM, 1)
C Select absolute error control
PARAM(10) = 1.0
C Print header
Output
ISTEP Time Y1 Y2
1 1.000 0.078 1.465
2 2.000 0.085 0.578
3 3.000 0.292 0.250
4 4.000 1.449 0.187
5 5.000 4.046 1.444
6 6.000 0.176 2.256
7 7.000 0.066 0.908
8 8.000 0.148 0.367
9 9.000 0.655 0.188
10 10.000 3.157 0.352
Example 2
This is a mildly stiff problem (F2) from the test set of Enright and Pryce (1987).
It is included here because it illustrates the inefficiency of requiring more function
evaluations with a nonstiff solver, for a requested accuracy, than would be
required using a stiff solver. Also, see IVPAG, page 646, Example 2, where the
problem is solved using a BDF method. The number of function evaluations may
vary, depending on the accuracy and other arithmetic characteristics of the
computer. The test problem has n = 2 equations:
Output
ISTEP Time Y1 Y2
1 24.000 0.688 0.002
2 48.000 0.634 0.002
3 72.000 0.589 0.002
4 96.000 0.549 0.002
5 120.000 0.514 0.002
6 144.000 0.484 0.002
7 168.000 0.457 0.002
8 192.000 0.433 0.001
9 216.000 0.411 0.001
10 240.000 0.391 0.001
Number of fcn calls with IVPRK = 2153.
Usage
CALL IVMRK (IDO, N, FCN, T, TEND, Y, YPRIME)
Arguments
IDO — Flag indicating the state of the computation. (Input/Output)
IDO State
1 Initial entry
2 Normal re-entry
3 Final call to release workspace
4 Return after a step
5 Return for function evaluation (reverse communication)
Normally, the initial call is made with IDO = 1. The routine then sets IDO = 2,
and this value is used for all but the last call that is made with IDO = 3. This final
call is used to release workspace, which was automatically allocated by the initial
call with IDO = 1.