D02HAF solves a two-point boundary value problem for a system of ordinary differential equations in the range . The system is written in the form:
and the derivatives are evaluated by FCN. Initially, boundary values of the variables must be specified, some at and some at . You must supply estimates of the remaining boundary values (called parameters below); the subroutine corrects these by a form of Newton iteration. It also calculates the complete solution on an equispaced mesh if required.
Starting from the known and estimated values of at , the subroutine integrates the equations from to (using a Runge–Kutta–Merson method). The differences between the values of at from integration and those specified initially should be zero for the true solution. (These differences are called residuals below.) The subroutine uses a generalized Newton method to reduce the residuals to zero, by calculating corrections to the estimated boundary values. This process is repeated iteratively until convergence is obtained, or until the routine can no longer reduce the residuals. See Hall and Watt (1976) for a simple discussion of shooting and matching techniques.
Hall G and Watt J M (ed.) (1976) Modern Numerical Methods for Ordinary Differential Equations Clarendon Press, Oxford
On exit: if , , or ,
, for , contains the solution at the point where the integration fails and the point of failure is returned in .
11: SDW – INTEGERInput
On entry: the second dimension of the array W as declared in the (sub)program from which D02HAF is called.
12: IFAIL – INTEGERInput/Output
For this routine, the normal use of IFAIL is extended to control the printing of error and warning messages as well as specifying hard or soft failure (see Section 3.3 in the Essential Introduction).
On entry: IFAIL must be set to a value with the decimal expansion , where each of the decimal digits , and must have a value of or .
specifies hard failure, otherwise soft failure;
suppresses error messages, otherwise error messages will be printed (see Section 6);
suppresses warning messages, otherwise warning messages will be printed (see Section 6).
The recommended value for inexperienced users is (i.e., hard failure with all messages printed).
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:
One or more of the parameters V, N, M1, SDW, or TOL is incorrectly set.
The step length for the integration is too short whilst calculating the residual (see Section 8).
No initial step length could be chosen for the integration whilst calculating the residual.
Note: or can occur due to choosing too small a value for TOL or due to choosing the wrong direction of integration. Try varying TOL and interchanging and . These error exits can also occur for very poor initial estimates of the unknown initial values and, in extreme cases, because D02HAF cannot be used to solve the problem posed.
As for but the error occurred when calculating the Jacobian of the derivatives of the residuals with respect to the parameters.
As for but the error occurred when calculating the derivatives of the residuals with respect to the parameters.
The calculated Jacobian has an insignificant column.
Note: , or usually indicate a badly scaled problem. You may vary the size of TOL or change to one of the more general routines D02HBF or D02SAF which afford more control over the calculations.
The linear algebra routine (F08KBF (DGESVD)) used has failed. This error exit should not occur and can be avoided by changing the estimated initial values.
The Newton iteration has failed to converge.
Note: can indicate poor initial estimates or a very difficult problem. Consider varying TOL if the residuals are small in the monitoring output. If the residuals are large try varying the initial estimates.
Indicates that a serious error has occurred in an internal call. Check all array subscripts and subroutine parameter lists in calls to D02HAF. Seek expert help.
If the process converges, the accuracy to which the unknown parameters are determined is usually close to that specified by you; the solution, if requested, may be determined to a required accuracy by varying TOL.
8 Further Comments
The time taken by D02HAF depends on the complexity of the system, and on the number of iterations required. In practice, integration of the differential equations is by far the most costly process involved.
Wherever it occurs in the routine, the error parameter TOL is used in ‘mixed’ form; that is TOL always occurs in expressions of the form . Though not ideal for every application, it is expected that this mixture of absolute and relative error testing will be adequate for most purposes.
You are strongly recommended to set IFAIL to obtain self-explanatory error messages, and also monitoring information about the course of the computation. You may select the channel numbers on which this output is to appear by calls of X04AAF (for error messages) or X04ABF (for monitoring information) – see Section 9 for an example. Otherwise the default channel numbers will be used, as specified in the Users' Note. The monitoring information produced at each iteration includes the current parameter values, the residuals and -norms: a basic norm and a current norm. At each iteration the aim is to find parameter values which make the current norm less than the basic norm. Both these norms should tend to zero as should the residuals. (They would all be zero if the exact parameters were used as input.) For more details, you may consult the specification of D02SAF, and especially the description of the parameter MONIT there.
The computing time for integrating the differential equations can sometimes depend critically on the quality of the initial estimates. If it seems that too much computing time is required and, in particular, if the values of the residuals printed by the monitoring routine are much larger than the expected values of the solution at , then the coding of FCN should be checked for errors. If no errors can be found, an independent attempt should be made to improve the initial estimates. In practical problems it is not uncommon for the differential equation to have a singular point at one or both ends of the range. Suppose is a singular point; then the derivatives in (1) (in Section 3) cannot be evaluated at , usually because one or more of the expressions for give overflow. In such a case it is necessary for you to take a short distance away from the singularity, and to find values for at the new value of (e.g., use the first one or two terms of an analytical (power series) solution). You should experiment with the new position of ; if it is taken too close to the singular point, the derivatives will be inaccurate, and the routine may sometimes fail with or or, in extreme cases, with an overflow condition. A more general treatment of singular solutions is provided by the subroutine D02HBF.
Another difficulty which often arises in practice is the case when one end of the range, say, is at infinity. You must approximate the end point by taking a finite value for , which is obtained by estimating where the solution will reach its asymptotic state. The estimate can be checked by repeating the calculation with a larger value of . If is very large, and if the matching point is also at , the numerical solution may suffer a considerable loss of accuracy in integrating across the range, and the program may fail with or . (In the former case, solutions from all initial values at are tending to the same curve at infinity.) The simplest remedy is to try to solve the equations with a smaller value of , and then to increase in stages, using each solution to give boundary value estimates for the next calculation. For problems where some terms in the asymptotic form of the solution are known, D02HBF will be more successful.
If the unknown quantities are not boundary values, but are eigenvalues or the length of the range or some other parameters occurring in the differential equations, D02HBF may be used.
This example finds the angle at which a projectile must be fired for a given range.
The differential equations are:
with the following boundary conditions:
The remaining boundary conditions are estimated as:
We write , , . To check the accuracy of the results the problem is solved twice with . and respectively. Note the call to X04ABF before the call to D02HAF.