NAG Library Routine Document
D02KEF
1 Purpose
D02KEF finds a specified eigenvalue of a regular or singular second-order Sturm–Liouville system on a finite or infinite interval, using a Pruefer transformation and a shooting method. It also reports values of the eigenfunction and its derivatives. Provision is made for discontinuities in the coefficient functions or their derivatives.
2 Specification
SUBROUTINE D02KEF ( |
XPOINT, M, MATCH, COEFFN, BDYVAL, K, TOL, ELAM, DELAM, HMAX, MAXIT, MAXFUN, MONIT, REPORT, IFAIL) |
INTEGER |
M, MATCH, K, MAXIT, MAXFUN, IFAIL |
REAL (KIND=nag_wp) |
XPOINT(M), TOL, ELAM, DELAM, HMAX(2,M) |
EXTERNAL |
COEFFN, BDYVAL, MONIT, REPORT |
|
3 Description
D02KEF has essentially the same purpose as
D02KDF with minor modifications to enable values of the eigenfunction to be obtained after convergence to the eigenvalue has been achieved.
It first finds a specified eigenvalue
of a Sturm–Liouville system defined by a self-adjoint differential equation of the second-order
together with appropriate boundary conditions at the two, finite or infinite, end points
and
. The functions
and
, which are real-valued, are defined by
COEFFN. The boundary conditions must be defined by
BDYVAL, and, in the case of a singularity at
or
, take the form of an asymptotic formula for the solution near the relevant end point.
When the final estimate
of the eigenvalue has been found, the routine integrates the differential equation once more with that value of
, and with initial conditions chosen so that the integral
is approximately one. When
is of the form
, which is the most common case,
represents the square of the norm of
induced by the inner product
with respect to which the eigenfunctions are mutually orthogonal. This normalization of
is only approximate, but experience shows that
generally differs from unity by only one or two per cent.
During this final integration the
REPORT is called at each integration mesh point
. Sufficient information is returned to permit you to compute
and
for printing or plotting. For reasons described in
Section 9.2, D02KEF passes across to
REPORT, not
and
, but the Pruefer variables
,
and
on which the numerical method is based. Their relationship to
and
is given by the equations
A specimen
REPORT is given in
Section 10 below.
For the theoretical basis of the numerical method to be valid, the following conditions should hold on the coefficient functions:
(a) |
must be nonzero and must not change sign throughout the interval ; and, |
(b) |
must not change sign throughout the interval for all relevant values of , and must not be identically zero as varies, for any . |
Points of discontinuity in the functions
and
or their derivatives are allowed, and should be included as ‘break-points’ in the array
XPOINT.
A good account of the theory of Sturm–Liouville systems, with some description of Pruefer transformations, is given in Chapter X of
Birkhoff and Rota (1962). An introduction to the use of Pruefer transformations for the numerical solution of eigenvalue problems arising from physics and chemistry is given in
Bailey (1966).
The scaled Pruefer method is described in a short note by
Pryce and Hargrave (1977) and in some detail in the technical report by
Pryce (1981).
4 References
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Bailey P B (1966) Sturm–Liouville eigenvalues via a phase function SIAM J. Appl. Math. 14 242–249
Banks D O and Kurowski I (1968) Computation of eigenvalues of singular Sturm–Liouville Systems Math. Comput. 22 304–310
Birkhoff G and Rota G C (1962) Ordinary Differential Equations Ginn & Co., Boston and New York
Pryce J D (1981) Two codes for Sturm–Liouville problems Technical Report CS-81-01 Department of Computer Science, Bristol University
Pryce J D and Hargrave B A (1977) The scaled Prüfer method for one-parameter and multi-parameter eigenvalue problems in ODEs IMA Numerical Analysis Newsletter 1(3)
5 Parameters
- 1: – REAL (KIND=nag_wp) arrayInput
-
On entry: the points where the boundary conditions computed by
BDYVAL are to be imposed, and also any break-points, i.e.,
to
must contain values
such that
with the following meanings:
(a) |
and are the left- and right-hand end points, and , of the domain of definition of the Sturm–Liouville system if these are finite. If either or is infinite, the corresponding value or may be a more-or-less arbitrarily ‘large’ number of appropriate sign. |
(b) |
and are the Boundary Matching Points (BMPs), that is the points at which the left and right boundary conditions computed in BDYVAL are imposed.
If the left-hand end point is a regular point then you should set , while if it is a singular point you must set . Similarly () if the right-hand end point is regular, and if it is singular. |
(c) |
The remaining points , if any, define ‘break-points’ which divide the interval into sub-intervals
Numerical integration of the differential equation is stopped and restarted at each break-point. In simple cases no break-points are needed. However, if or are given by different formulae in different parts of the interval, then integration is more efficient if the range is broken up by break-points in the appropriate way. Similarly points where any jumps occur in or , or in their derivatives up to the fifth-order, should appear as break-points.
Examples are given in Sections 9 and 10. XPOINT determines the position of the Shooting Matching Point (SMP), as explained in Section 9.3. |
Constraint:
.
- 2: – INTEGERInput
-
On entry: the number of points in the array
XPOINT.
Constraint:
.
- 3: – INTEGERInput/Output
-
On entry: must be set to the index of the ‘break-point’ to be used as the matching point (see
Section 9.3). If
MATCH is set to a value outside the range
then a default value is taken, corresponding to the break-point nearest the centre of the interval
.
On exit: the index of the break-point actually used as the matching point.
- 4: – SUBROUTINE, supplied by the user.External Procedure
-
COEFFN must compute the values of the coefficient functions
and
for given values of
and
.
Section 3 states the conditions which
and
must satisfy. See
Sections 9.4 and
10 for examples.
The specification of
COEFFN is:
INTEGER |
JINT |
REAL (KIND=nag_wp) |
P, Q, DQDL, X, ELAM |
|
- 1: – REAL (KIND=nag_wp)Output
-
On exit: the value of for the current value of .
- 2: – REAL (KIND=nag_wp)Output
-
On exit: the value of for the current value of and the current trial value of .
- 3: – REAL (KIND=nag_wp)Output
-
On exit: the value of
for the current value of
and the current trial value of
. However
DQDL is only used in error estimation and, in the rare cases where it may be difficult to evaluate, an approximation (say to within
) will suffice.
- 4: – REAL (KIND=nag_wp)Input
-
On entry: the current value of .
- 5: – REAL (KIND=nag_wp)Input
-
On entry: the current trial value of the eigenvalue parameter .
- 6: – INTEGERInput
-
On entry: the index
of the sub-interval
(see specification of
XPOINT) in which
lies.
COEFFN must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02KEF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 5: – SUBROUTINE, supplied by the user.External Procedure
-
BDYVAL must define the boundary conditions. For each end point,
BDYVAL must return (in
YL or
YR) values of
and
which are consistent with the boundary conditions at the end points; only the ratio of the values matters. Here
is a given point (
XL or
XR) equal to, or close to, the end point.
For a
regular end point (
, say),
, a boundary condition of the form
can be handled by returning constant values in
YL, e.g.,
and
.
For a
singular end point however,
and
will in general be functions of
XL and
ELAM, and
and
functions of
XR and
ELAM, usually derived analytically from a power-series or asymptotic expansion. Examples are given in
Sections 9.5 and
10.
The specification of
BDYVAL is:
REAL (KIND=nag_wp) |
XL, XR, ELAM, YL(3), YR(3) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: if
is a regular end point of the system (so that
), then
XL contains
. If
is a singular point (so that
), then
XL contains a point
such that
.
- 2: – REAL (KIND=nag_wp)Input
-
On entry: if
is a regular end point of the system (so that
), then
XR contains
. If
is a singular point (so that
), then
XR contains a point
such that
.
- 3: – REAL (KIND=nag_wp)Input
-
On entry: the current trial value of .
- 4: – REAL (KIND=nag_wp) arrayOutput
-
On exit: and should contain values of and respectively (not both zero) which are consistent with the boundary condition at the left-hand end point, given by . should not be set.
- 5: – REAL (KIND=nag_wp) arrayOutput
-
On exit: and should contain values of and respectively (not both zero) which are consistent with the boundary condition at the right-hand end point, given by . should not be set.
BDYVAL must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02KEF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 6: – INTEGERInput
-
On entry:
, the index of the required eigenvalue when the eigenvalues are ordered
Constraint:
.
- 7: – REAL (KIND=nag_wp)Input
-
On entry: the tolerance parameter which determines the accuracy of the computed eigenvalue. The error estimate held in
DELAM on exit satisfies the mixed absolute/relative error test
where
ELAM is the final estimate of the eigenvalue.
DELAM is usually somewhat smaller than the right-hand side of
(1) but not several orders of magnitude smaller.
Constraint:
.
- 8: – REAL (KIND=nag_wp)Input/Output
-
On entry: an initial estimate of the eigenvalue .
On exit: the final computed estimate, whether or not an error occurred.
- 9: – REAL (KIND=nag_wp)Input/Output
-
On entry: an indication of the scale of the problem in the
-direction.
DELAM holds the initial ‘search step’ (positive or negative). Its value is not critical, but the first two trial evaluations are made at
ELAM and
, so the routine will work most efficiently if the eigenvalue lies between these values. A reasonable choice (if a closer bound is not known) is half the distance between adjacent eigenvalues in the neighbourhood of the one sought. In practice, there will often be a problem, similar to the one in hand but with known eigenvalues, which will help one to choose initial values for
ELAM and
DELAM.
If on entry, it is given the default value of .
On exit: if
,
DELAM holds an estimate of the absolute error in the computed eigenvalue, that is
. (In
Section 9.2 we discuss the assumptions under which this is true.) The true error is rarely more than twice, or less than a tenth, of the estimated error.
If
,
DELAM may hold an estimate of the error, or its initial value, depending on the value of
IFAIL. See
Section 6 for further details.
- 10: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry:
should contain a maximum step size to be used by the differential equation code in the
th sub-interval
(as described in the specification of parameter
XPOINT), for
. If it is zero the routine generates a maximum step size internally.
It is recommended that
be set to zero unless the coefficient functions
and
have features (such as a narrow peak) within the
th sub-interval that could be ‘missed’ if a long step were taken. In such a case
should be set to about half the distance over which the feature should be observed. Too small a value will increase the computing time for the routine. See
Section 9 for further suggestions.
The rest of the array is used as workspace.
On exit:
and
contain the sensitivity coefficients
, described in
Section 9.6. Other entries contain diagnostic output in the case of an error exit (see
Section 6).
- 11: – INTEGERInput/Output
-
On entry: a bound on
, the number of root-finding iterations allowed, that is the number of trial values of
that are used. If
, no such bound is assumed. (See also
MAXFUN.)
Suggested value:
.
On exit: will have been decreased by the number of iterations actually performed, whether or not it was positive on entry.
- 12: – INTEGERInput
-
On entry: a bound on
, the number of calls to
COEFFN made in any one root-finding iteration. If
, no such bound is assumed.
Suggested value:
.
MAXFUN and
MAXIT may be used to limit the computational cost of a call to D02KEF, which is roughly proportional to
.
- 13: – SUBROUTINE, supplied by the NAG Library or the user.External Procedure
-
MONIT is called by D02KEF at the end of each root-finding iteration and allows you to monitor the course of the computation by printing out the parameters (see
Section 10 for an example).
If no monitoring is required, the dummy (sub)program D02KAY may be used. (D02KAY is included in the NAG Library.)
The specification of
MONIT is:
INTEGER |
NIT, IFLAG |
REAL (KIND=nag_wp) |
ELAM, FINFO(15) |
|
- 1: – INTEGERInput
-
On entry: the current value of the parameter
MAXIT of D02KEF, this is decreased by one at each iteration.
- 2: – INTEGERInput
-
On entry: describes what phase the computation is in.
- An error occurred in the computation at this iteration; an error exit from D02KEF with will follow.
- The routine is trying to bracket the eigenvalue .
- The routine is converging to the eigenvalue (having already bracketed it).
- 3: – REAL (KIND=nag_wp)Input
-
On entry: the current trial value of .
- 4: – REAL (KIND=nag_wp) arrayInput
-
On entry: information about the behaviour of the shooting method, and diagnostic information in the case of errors. It should not normally be printed in full if no error has occurred (that is, if
), though the first few components may be of interest to you. In case of an error (
) all the components of
FINFO should be printed.
The contents of
FINFO are as follows:
- The current value of the ‘miss-distance’ or ‘residual’ function on which the shooting method is based. (See Section 9.2 for further information.) is set to zero if .
- An estimate of the quantity defined as follows. Consider the perturbation in the miss-distance that would result if the local error in the solution of the differential equation were always positive and equal to its maximum permitted value. Then is the perturbation in that would have the same effect on . Thus, at the zero of is an approximate bound on the perturbation of the zero (that is the eigenvalue) caused by errors in numerical solution. If is very large then it is possible that there has been a programming error in COEFFN such that is independent of . If this is the case, an error exit with should follow. is set to zero if .
- The number of internal iterations, using the same value of and tighter accuracy tolerances, needed to bring the accuracy (that is, the value of ) to an acceptable value. Its value should normally be , and should almost never exceed .
- The number of calls to COEFFN at this iteration.
- The number of successful steps taken by the internal differential equation solver at this iteration. A step is successful if it is used to advance the integration.
- The number of unsuccessful steps used by the internal integrator at this iteration.
- The number of successful steps at the maximum step size taken by the internal integrator at this iteration.
- Not used.
- to
- Set to zero, unless in which case they hold the following values describing the point of failure:
- The index of the sub-interval where failure occurred, in the range to . In case of an error in BDYVAL, it is set to or depending on whether the left or right boundary condition caused the error.
- The value of the independent variable, , the point at which the error occurred. In case of an error in BDYVAL, it is set to the value of XL or XR as appropriate (see the specification of BDYVAL).
- , ,
- The current values of the Pruefer dependent variables , and respectively. These are set to zero in case of an error in BDYVAL.
- The local-error tolerance being used by the internal integrator at the point of failure. This is set to zero in the case of an error in BDYVAL.
- The last integration mesh point. This is set to zero in the case of an error in BDYVAL.
MONIT must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02KEF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 14: – SUBROUTINE, supplied by the user.External Procedure
-
REPORT provides the means by which you may compute the eigenfunction
and its derivative at each integration mesh point
. (See
Section 9 for an example.)
The specification of
REPORT is:
SUBROUTINE REPORT ( |
X, V, JINT) |
INTEGER |
JINT |
REAL (KIND=nag_wp) |
X, V(3) |
|
- 1: – REAL (KIND=nag_wp)Input
-
On entry: the current value of the independent variable
. See
Section 9.3 for the order in which values of
are supplied.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: , , hold the current values of the Pruefer variables , , respectively.
- 3: – INTEGERInput
-
On entry: indicates the sub-interval between break-points in which
X lies exactly as for
COEFFN,
except that at the extreme left-hand end point (when
)
JINT is set to
and at the extreme right-hand end point (when
)
JINT is set to
.
REPORT must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02KEF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 15: – 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:
-
A parameter error. All parameters (except
IFAIL) are left unchanged. The reason for the error is shown by the value of
as follows:
: |
; |
: |
; |
: |
; |
: |
to are not in ascending order. gives the position in XPOINT where this was detected. |
-
At some call to
BDYVAL, invalid values were returned, that is, either
, or
(a programming error in
BDYVAL). See the last call of
MONIT for details.
This error exit will also occur if
is zero at the point where the boundary condition is imposed. Probably
BDYVAL was called with
XL equal to a singular end point
or with
XR equal to a singular end point
.
-
At some point between
XL and
XR the value of
computed by
COEFFN became zero or changed sign. See the last call of
MONIT for details.
-
on entry, and after
MAXIT iterations the eigenvalue had not been found to the required accuracy.
-
The ‘bracketing’ phase (with parameter
IFLAG of the
MONIT equal to
) failed to bracket the eigenvalue within ten iterations. This is caused by an error in formulating the problem (for example,
is independent of
), or by very poor initial estimates of
ELAM and
DELAM.
On exit,
ELAM and
give the end points of the interval within which no eigenvalue was located by the routine.
-
on entry, and the last iteration was terminated because more than
MAXFUN calls to
COEFFN were used. See the last call of
MONIT for details.
-
To obtain the desired accuracy the local error tolerance was set so small at the start of some sub-interval that the differential equation solver could not choose an initial step size large enough to make significant progress. See the last call of
MONIT for diagnostics.
-
At some point inside a sub-interval the step size in the differential equation solver was reduced to a value too small to make significant progress (for the same reasons as with
). This could be due to pathological behaviour of
and
or to an unreasonable accuracy requirement or to the current value of
making the equations ‘stiff’. See the last call of
MONIT for details.
-
TOL is too small for the problem being solved and the
machine precision is being used. The final value of
ELAM should be a very good approximation to the eigenvalue.
-
C05AZF, called by D02KEF, has terminated with the error exit corresponding to a pole of the residual function
. This error exit should not occur, but if it does, try solving the problem again with a smaller value for
TOL.
-
A serious error has occurred in an internal call. Check all (sub)program calls and array dimensions. Seek expert help.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
Note: error exits with
,
,
,
,
or
are caused by being unable to set up or solve the differential equation at some iteration and will be immediately preceded by a call of
MONIT giving diagnostic information. For other errors, diagnostic information is contained in
, for
, where appropriate.
7 Accuracy
See the discussion in
Section 9.2.
8 Parallelism and Performance
Not applicable.
The time taken by D02KEF depends on the complexity of the coefficient functions, whether they or their derivatives are rapidly changing, the tolerance demanded, and how many iterations are needed to obtain convergence. The amount of work per iteration is roughly doubled when
TOL is divided by
. To make the most economical use of the routine, one should try to obtain good initial values for
ELAM and
DELAM, and, where appropriate, good asymptotic formulae. Also the boundary matching points should not be set unnecessarily close to singular points. The extra time needed to compute the eigenfunction is principally the cost of one additional integration once the eigenvalue has been found.
A shooting method, for differential equation problems containing unknown parameters, relies on the construction of a ‘miss-distance function’, which for given trial values of the parameters measures how far the conditions of the problem are from being met. The problem is then reduced to one of finding the values of the parameters for which the miss-distance function is zero, that is to a root-finding process. Shooting methods differ mainly in how the miss-distance is defined.
D02KEF defines a miss-distance
based on the rotation about the origin of the point
in the Phase Plane as the solution proceeds from
to
. The
boundary conditions define the ray (i.e., two-sided line through the origin) on which
should start, and the ray on which it should finish. The
eigenvalue defines the total number of half-turns it should make. Numerical solution is actually done by ‘shooting forward’ from
and ‘shooting backward’ from
to a matching point
. Then
is taken as the angle between the rays to the two resulting points
and
. A relative scaling of the
and
axes, based on the behaviour of the coefficient functions
and
, is used to improve the numerical behaviour.
Figure 1
The resulting function is monotonic over , increasing if and decreasing if , with a unique zero at the desired eigenvalue . The routine measures in units of a half-turn. This means that as increases, varies by about as each eigenvalue is passed. (This feature implies that the values of at successive iterations – especially in the early stages of the iterative process – can be used with suitable extrapolation or interpolation to help the choice of initial estimates for eigenvalues near to the one currently being found.)
The routine actually computes a value for
with errors, arising from the local errors of the differential equation code and from the asymptotic formulae provided by you if singular points are involved. However, the error estimate output in
DELAM is usually fairly realistic, in that the actual error
is within an order of magnitude of
DELAM.
We pass the values of
,
,
across through
REPORT rather than converting them to values of
,
inside D02KEF, for the following reasons. First, there may be cases where auxiliary quantities can be more accurately computed from the Pruefer variables than from
and
. Second, in singular problems on an infinite interval
and
may underflow towards the end of the range, whereas the Pruefer variables remain well-behaved. Third, with high-order eigenvalues (and therefore highly oscillatory eigenfunctions) the eigenfunction may have a complete oscillation (or more than one oscillation) between two mesh points, so that values of
and
at mesh points give a very poor representation of the curve. The probable behaviour of the Pruefer variables in this case is that
and
vary slowly whilst
increases quickly: for all three Pruefer variables linear interpolation between the values at adjacent mesh points is probably sufficiently accurate to yield acceptable intermediate values of
,
,
(and hence of
) for graphical purposes.
Similar considerations apply to the exponentially decaying ‘tails’ of the eigenfunctions that often occur in singular problems. Here has approximately constant value whilst increases rapidly in the direction of integration, though the step length is generally fairly small over such a range.
If the solution is output through
REPORT at
values which are too widely spaced, the step length can be controlled by choosing
HMAX suitably, or, preferably, by reducing
TOL. Both these choices will lead to more accurate eigenvalues and eigenfunctions but at some computational cost.
This point is always one of the values
in array
XPOINT. It may be specified using the parameter
MATCH. The default value is chosen to be the value of that
,
, that lies closest to the middle of the interval
. If there is a tie, the rightmost candidate is chosen. In particular if there are no break-points, then
(
); that is, the shooting is from left to right in this case. A break-point may be inserted purely to move
to an interior point of the interval, even though the form of the equations does not require it. This often speeds up convergence especially with singular problems.
Note that the shooting method used by the code integrates first from the left-hand end
, then from the right-hand end
, to meet at the matching point
in the middle. This will of course be reflected in printed or graphical output. The diagram shows a possible sequence of nine mesh points
through
in the order in which they appear, assuming there are just two sub-intervals (so
).
Figure 2
Since the shooting method usually fails to match up the two ‘legs’ of the curve exactly, there is bound to be a jump in
, or in
or both, at the matching point
. The code in fact ‘shares’ the discrepancy out so that both
and
have a jump. A large jump does
not imply an inaccurate eigenvalue, but implies either
(a) |
a badly chosen matching point: if has a ‘humped’ shape, should be chosen near the maximum value of , especially if is negative at the ends of the interval; |
(b) |
an inherently ill-conditioned problem, typically one where another eigenvalue is pathologically close to the one being sought. In this case it is extremely difficult to obtain an accurate eigenfunction. |
In
Section 10, we find the 11th eigenvalue and corresponding eigenfunction of the equation
the boundary conditions being that
should remain bounded as
tends to
and
tends to
. The coding of this problem is discussed in detail in
Section 9.5.
The choice of matching point
is open. If we choose
as in
D02KDF example program we find that the exponentially increasing component of the solution dominates and we get extremely inaccurate values for the eigenfunction (though the eigenvalue is determined accurately). The values of the eigenfunction calculated with
are given schematically in
Figure 3.
Figure 3
If we choose
as the maximum of the hump in
(see item
(a) above) we instead obtain the accurate results given in
Figure 4
Figure 4
Coding
COEFFN is straightforward except when break-points are needed. The examples below show:
(a) |
a simple case, |
(b) |
a case in which discontinuities in the coefficient functions or their derivatives necessitate break-points, and |
(c) |
a case where break-points together with the HMAX parameter are an efficient way to deal with a coefficient function that is well-behaved except over one short interval. |
(Some of these cases are among the examples in
Section 10.)
Example A
The modified Bessel equation
Assuming the interval of solution does not contain the origin and dividing through by
, we have
and
. The code could be
SUBROUTINE COEFFN (P,Q,DQDL,X,ELAM,JINT)
...
P = X
Q = ELAM*X - NU*NU/X
DQDL = X
RETURN
END
where
NU (standing for
) is a real variable that might be defined in a DATA statement, or might be in user-declared COMMON so that its value could be set in the main program.
Example B
The Schroedinger equation
where
over some interval ‘approximating to
’, say
. Here we need break-points at
, forming three sub-intervals
,
,
. The code could be
SUBROUTINE COEFFN(P,Q,DQDL,X,ELAM,JINT)
...
IF (JINT.EQ.2) THEN
Q = ELAM + X*X - 10.0E0
ELSE
Q = ELAM + 6.0E0/ABS(X)
ENDIF
P = 1.0E0
DQDL = 1.0E0
RETURN
END
The array
XPOINT would contain the values
,
,
,
,
,
and
would be
. The choice of appropriate values for
and
depends on the form of the asymptotic formula computed by
BDYVAL and the technique is discussed in
Section 9.5.
Example C
Here
is nearly constant over the range except for a sharp inverted spike over approximately
. There is a danger that the routine will build up to a large step size and ‘step over’ the spike without noticing it. By using break-points – say at
– one can restrict the step size near the spike without impairing the efficiency elsewhere.
The code for
COEFFN could be
SUBROUTINE COEFFN(P,Q,DQDL,X,ELAM,JINT)
...
P = 1.0E0
DQDL = 1.0E0 - 2.0E0*EXP(-100.0E0*X*X)
Q = ELAM*DQDL
RETURN
END
XPOINT might contain
,
,
,
,
,
(assuming
are regular points) and
would be
.
, for
, might contain
,
and
.
Quoting from page 243 of
Bailey (1966): ‘Usually ... the differential equation has two essentially different types of solution near a singular point, and the boundary condition there merely serves to distinguish one kind from the other. This is the case in all the standard examples of mathematical physics.’
In most cases the behaviour of the ratio
near the point is quite different for the two types of solution. Essentially what you provide through the
BDYVAL is an approximation to this ratio, valid as
tends to the singular point (SP).
You must decide (a) how accurate to make this approximation or asymptotic formula, for example how many terms of a series to use, and (b) where to place the boundary matching point (BMP) at which the numerical solution of the differential equation takes over from the asymptotic formula. Taking the BMP closer to the SP will generally improve the accuracy of the asymptotic formula, but will make the computation more expensive as the Pruefer differential equations generally become progressively more ill-behaved as the SP is approached. You are strongly recommended to experiment with placing the BMPs. In many singular problems quite crude asymptotic formulae will do. To help you avoid needlessly accurate formulae, D02KEF outputs two ‘sensitivity coefficients’
which estimate how much the errors at the BMPs affect the computed eigenvalue. They are described in detail in
Section 9.6.
Example of coding BDYVAL: The example below illustrates typical situations:
the boundary conditions being that
should remain bounded as
tends to
and
tends to
.
At the end
there is one solution that behaves like
and another that behaves like
. For the first of these solutions
is asymptotically
while for the second it is asymptotically
. Thus the desired ratio is specified by setting
At the end
the equation behaves like Airy's equation shifted through
, i.e., like
where
, so again there are two types of solution. The solution we require behaves as
and the other as
Hence, the desired solution has
so that we could set
and
. The complete subroutine might thus be
SUBROUTINE BDYVAL (XL,XR,ELAM,YL,YR)
real XL, XR, ELAM, YL(3), YR(3)
YL(1) = XL
YL(2) = 2.0E0
YR(1) = 1.0E0
YR(2) = -SQRT(XR-ELAM)
RETURN
END
Clearly for this problem it is essential that any value given by D02KEF to
XR is well to the right of the value of
ELAM, so that you must vary the right-hand BMP with the eigenvalue index
. One would expect
to be near the
th zero of the Airy function
, so there is no problem estimating
ELAM.
More accurate asymptotic formulae are easily found: near
by the standard Frobenius method, and near
by using standard asymptotics for
,
, (see page 448 of
Abramowitz and Stegun (1972)).
For example, by the Frobenius method the solution near
has the expansion
with
This yields
The sensitivity parameters
,
(held in
and
on output) estimate the effect of errors in the boundary conditions. For sufficiently small errors
,
in
and
respectively, the relations
are satisfied, where the subscripts
,
denote errors committed at the left- and right-hand BMPs respectively, and
denotes the consequent error in the computed eigenvalue.
This is a pitfall to beware of at a singular point. If the BMP is chosen so far from the SP that a zero of the desired eigenfunction lies in between them, then the routine will fail to ‘notice’ this zero. Since the index of
of an eigenvalue is the number of zeros of its eigenfunction, the result will be that
(a) |
the wrong eigenvalue will be computed for the given index – in fact some will be found where ; |
(b) |
the same index can cause convergence to any of several eigenvalues depending on the initial values of ELAM and DELAM. |
It is up to you to take suitable precautions – for instance by varying the position of the BMPs in the light of knowledge of the asymptotic behaviour of the eigenfunction at different eigenvalues.
10 Example
This example finds the 11th eigenvalue and eigenfunction of the example of
Section 9.5, using the simple asymptotic formulae for the boundary conditions.
Comparison of the results from this example program with the corresponding results from
D02KDF example program shows that similar output is produced from
MONIT, followed by the eigenfunction values from
REPORT, and then a further line of information from
MONIT (corresponding to the integration to find the eigenfunction). Final information is printed within the example program exactly as with
D02KDF.
Note the discrepancy at the matching point (, the maximum of , in this case) between the solutions obtained by integrations from left- and right-hand end points.
10.1 Program Text
Program Text (d02kefe.f90)
10.2 Program Data
Program Data (d02kefe.d)
10.3 Program Results
Program Results (d02kefe.r)