D02EJF integrates a stiff system of first-order ordinary differential equations over an interval with suitable initial conditions, using a variable-order, variable-step method implementing the Backward Differentiation Formulae (BDF), until a user-specified function, if supplied, of the solution is zero, and returns the solution at points specified by you, if desired.
D02EJF advances the solution of a system of ordinary differential equations
from to using a variable-order, variable-step method implementing the BDF. The system is defined by FCN, which evaluates in terms of and (see Section 5). The initial values of must be given at .
The solution is returned via the OUTPUT at points specified by you, if desired: this solution is obtained by interpolation on solution values produced by the method. As the integration proceeds a check can be made on the user-specified function to determine an interval where it changes sign. The position of this sign change is then determined accurately by interpolation to the solution. It is assumed that is a continuous function of the variables, so that a solution of can be determined by searching for a change in sign in . The accuracy of the integration, the interpolation and, indirectly, of the determination of the position where , is controlled by the parameters TOL and RELABS. The Jacobian of the system may be supplied in PEDERV, if it is available.
Hall G and Watt J M (ed.) (1976) Modern Numerical Methods for Ordinary Differential Equations Clarendon Press, Oxford
1: X – REAL (KIND=nag_wp)Input/Output
On entry: the initial value of the independent variable .
On exit: if G is supplied by you, X contains the point where , unless anywhere on the range X to XEND, in which case, X will contain XEND. If G is not supplied X contains XEND, unless an error has occurred, when it contains the value of at the error.
2: XEND – REAL (KIND=nag_wp)Input
On entry: the final value of the independent variable. If , integration will proceed in the negative direction.
On entry: , the value of the independent variable.
2: Y() – REAL (KIND=nag_wp) arrayInput
On entry: , for , the value of the variable.
3: PW() – REAL (KIND=nag_wp) arrayOutput
On exit: must contain the value of
, for and .
PEDERV must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02EJF is called. Parameters denoted as Input must not be changed by this procedure.
If you do not wish to supply the Jacobian, the actual parameter PEDERVmust be the
dummy routine D02EJY. (D02EJY is included in the NAG Library.)
7: TOL – REAL (KIND=nag_wp)Input/Output
On entry: must be set to a positive tolerance for controlling the error in the integration. Hence TOL affects the determination of the position where , if G is supplied.
D02EJF has been designed so that, for most problems, a reduction in TOL leads to an approximately proportional reduction in the error in the solution. However, the actual relation between TOL and the accuracy achieved cannot be guaranteed. You are strongly recommended to call D02EJF with more than one value for TOL and to compare the results obtained to estimate their accuracy. In the absence of any prior knowledge, you might compare the results obtained by calling D02EJF with and if correct decimal digits are required in the solution.
On exit: normally unchanged. However if the range X to XEND is so short that a small change in TOL is unlikely to make any change in the computed solution, then, on return, TOL has its sign changed.
8: RELABS – CHARACTER(1)Input
On entry: the type of error control. At each step in the numerical solution an estimate of the local error, , is made. For the current step to be accepted the following condition must be satisfied:
where is a small machine-dependent number and is an estimate of the local error at , computed internally. If the appropriate condition is not satisfied, the step size is reduced and the solution is recomputed on the current step. If you wish to measure the error in the computed solution in terms of the number of correct decimal places, then RELABS should be set to 'A' on entry, whereas if the error requirement is in terms of the number of correct significant digits, then RELABS should be set to 'R'. If you prefer a mixed error test, then RELABS should be set to 'M', otherwise if you have no preference, RELABS should be set to the default 'D'. Note that in this case 'D' is taken to be 'R'.
, , or .
9: OUTPUT – SUBROUTINE, supplied by the NAG Library or the user.External Procedure
OUTPUT permits access to intermediate values of the computed solution (for example to print or plot them), at successive user-specified points. It is initially called by D02EJF with (the initial value of ). You must reset XSOL to the next point (between the current XSOL and XEND) where OUTPUT is to be called, and so on at each call to OUTPUT. If, after a call to OUTPUT, the reset point XSOL is beyond XEND, D02EJF will integrate to XEND with no further calls to OUTPUT; if a call to OUTPUT is required at the point , then XSOL must be given precisely the value XEND.
On entry: the dimension of the array W as declared in the (sub)program from which D02EJF is called.
13: IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to , . If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is . When the value is used it is essential to test the value of IFAIL on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6 Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
With the given value of TOL, no further progress can be made across the integration range from the current point . (See Section 5 for a discussion of this error test.) The components contain the computed values of the solution at the current point . If you have supplied G, then no point at which changes sign has been located up to the point .
TOL is too small for D02EJF to take an initial step. X and retain their initial values.
XSOL lies behind X in the direction of integration, after the initial call to OUTPUT, if the OUTPUT option was selected.
A value of XSOL returned by the OUTPUT lies behind the last value of XSOL in the direction of integration, if the OUTPUT option was selected.
At no point in the range X to XEND did the function change sign, if G was supplied. It is assumed that has no solution.
A serious error has occurred in an internal call to the specified routine. Check all subroutine calls and array dimensions. Seek expert help.
A serious error has occurred in an internal call to an interpolation routine. Check all (sub)program calls and array dimensions. Seek expert help.
The accuracy of the computation of the solution vector Y may be controlled by varying the local error tolerance TOL. In general, a decrease in local error tolerance should lead to an increase in accuracy. You are advised to choose unless you have a good reason for a different choice. It is particularly appropriate if the solution decays.
If the problem is a root-finding one, then the accuracy of the root determined will depend strongly on and
, for . Large values for these quantities may imply large errors in the root.
8 Further Comments
If more than one root is required, then to determine the second and later roots D02EJF may be called again starting a short distance past the previously determined roots. Alternatively you may construct your own root-finding code using D02NBF (and other routines in sub-chapter D02M–N), C05AZF and D02XKF.
If it is easy to code, you should supply PEDERV. However, it is important to be aware that if PEDERV is coded incorrectly, a very inefficient integration may result and possibly even a failure to complete the integration (see ).
We illustrate the solution of five different problems. In each case the differential system is the well-known stiff Robertson problem.
with initial conditions , at . We solve each of the following problems with local error tolerances and .
To integrate to producing output at intervals of until a point is encountered where . The Jacobian is calculated numerically.
As (i) but with the Jacobian calculated analytically.