naginterfaces.library.ode.sl2_reg_finite¶
- naginterfaces.library.ode.sl2_reg_finite(xl, xr, coeffn, bcond, k, tol, elam, delam, monit=None, data=None)[source]¶
sl2_reg_finite
finds a specified eigenvalue of a regular second-order Sturm–Liouville system defined on a finite range, using a Pruefer transformation and a shooting method.For full information please refer to the NAG Library document for d02ka
https://support.nag.com/numeric/nl/nagdoc_30.1/flhtml/d02/d02kaf.html
- Parameters
- xlfloat
The left- and right-hand end points and respectively, of the interval of definition of the problem.
- xrfloat
The left- and right-hand end points and respectively, of the interval of definition of the problem.
- coeffncallable (p, q, dqdl) = coeffn(x, elam, jint, data=None)
must compute the values of the coefficient functions and for given values of and . Notes states the conditions which and must satisfy.
- Parameters
- xfloat
The current value of .
- elamfloat
The current trial value of the eigenvalue argument .
- jintint
This argument is included for compatibility with the more complex function
sl2_breaks_vals()
(which is called bysl2_reg_finite
).Need not be set.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- pfloat
The value of for the current value of .
- qfloat
The value of for the current value of and the current trial value of .
- dqdlfloat
The value of for the current value of and the current trial value of . However 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.
- bcondfloat, array-like, shape
and must contain the numbers , specifying the left-hand boundary condition in the form
where .
and must contain , such that
where .
Note the occurrence of , in these formulae.
- kint
, the index of the required eigenvalue when the eigenvalues are ordered
- tolfloat
The tolerance argument which determines the accuracy of the computed eigenvalue. The error estimate held in on exit satisfies the mixed absolute/relative error test
where is the final estimate of the eigenvalue. is usually somewhat smaller than the right-hand side of (1) but not several orders of magnitude smaller.
- elamfloat
An initial estimate of the eigenvalue .
- delamfloat
An indication of the scale of the problem in the -direction. holds the initial ‘search step’ (positive or negative). Its value is not critical, but the first two trial evaluations are made at and , so the function will work most efficiently if the eigenvalue lies between these values. A reasonable choice (if a closer bound is not known) is about 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 and .
If on entry, it is given the default value of .
- monitNone or callable monit(nit, iflag, elam, finfo, data=None), optional
Note: if this argument is None then a NAG-supplied facility will be used.
is called by
sl2_reg_finite
at the end of each iteration for and allows you to monitor the course of the computation by printing out the arguments.- Parameters
- nitint
15 minus the number of iterations used so far in the search for . (Up to iterations are permitted.)
- iflagint
Describes what phase the computation is in.
An error occurred in the computation at this iteration; an error exit from
sl2_reg_finite
will follow.The function is trying to bracket the eigenvalue .
The function is converging to the eigenvalue (having already bracketed it).
Normally, the iteration will terminate after a sequence of iterates with , but occasionally the bracket on thus determined will not be sufficiently small and the iteration will be repeated with tighter accuracy control.
- elamfloat
The current trial value of .
- finfofloat, ndarray, shape
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 should be printed.
The contents of are as follows:
The current value of the ‘miss-distance’ or ‘residual’ function on which the shooting method is based. in theory. This 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 such that is independent of . If this is the case, an error exit with = 5 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 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:
1 or depending on whether integration was in a forward or backward direction at the time of failure.
The value of the independent variable, , the point at which the error occurred.
, ,
The current values of the Pruefer dependent variables , and respectively. See Notes for sl2_breaks_funs for a description of these variables.
The local-error tolerance being used by the internal integrator at the point of failure.
The last integration mesh point.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- bcondfloat, ndarray, shape
and hold values estimating the sensitivity of the computed eigenvalue to changes in the boundary conditions. These values should only be of interest if the boundary conditions are, in some sense, an approximation to some ‘true’ boundary conditions. For example, if the range [, ] should really be but instead has been given a large value and the boundary conditions at infinity applied at , the sensitivity argument may be of interest. Refer to Further Comments, for the actual meaning of and .
- elamfloat
The final computed estimate, whether or not an error occurred.
- delamfloat
If no exception or warning is raised, holds an estimate of the absolute error in the computed eigenvalue, that is , where is the true eigenvalue.
If an exception is raised, may hold an estimate of the error, or its initial value, depending on the value of .
See Exceptions for further details.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
The constraint on the left- or right-hand boundary condition has been violated.
- (errno )
The function became zero or changed sign in the interval .
- (errno )
After iterations the eigenvalue had not been found to the required accuracy.
- (errno )
The bracketing phase failed to bracket the eigenvalue within ten iterations. This may be due to an error in formulating the problem (for example, is independent of ), or by very poor initial estimates for the eigenvalue and search step.
- (errno )
Too small a step size was required at the start of a sub-interval to obtain the desired accuracy.
- (errno )
Too small a step size was required during solution in a sub-interval to obtain the desired accuracy.
- (errno )
An internal error has occurred corresponding to a pole of the matching function. Try solving the problem again with a smaller tolerance.
- Warns
- NagAlgorithmicWarning
- (errno )
The tolerance set is too small for the problem being solved and the machine precision being used. The local eigenvalue estimate returned is likely to be a very good approximation.
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
sl2_reg_finite
finds a specified eigenvalue of a Sturm–Liouville system defined by a self-adjoint differential equation of the second-ordertogether with boundary conditions of the form
at the two, finite, end points and . The functions and , which are real-valued, are defined by .
For the theoretical basis of the numerical method to be valid, the following conditions should hold on the coefficient functions:
must be nonzero and must not change sign throughout the closed interval ;
must not change sign and must be nonzero throughout the open interval and for all relevant values of , and must not be identically zero as varies, for any relevant value ; and,
and should (as functions of ) have continuous derivatives, preferably up to the fourth-order, on . The differential equation code used will integrate through mild discontinuities, but probably with severely reduced efficiency. Therefore, if and violate this condition,
sl2_breaks_vals()
should be used.
The eigenvalue is determined by a shooting method based on a Pruefer transformation of the differential equations. Providing certain assumptions are met, the computed value of will be correct to within a mixed absolute/relative error specified by .
sl2_reg_finite
is a driver function for the more complicated functionsl2_breaks_vals()
whose specification provides more details of the techniques used.A good account of the theory of Sturm–Liouville systems, with some description of Pruefer transformations, is given in Module 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).
- References
Bailey, P B, 1966, Sturm–Liouville eigenvalues via a phase function, SIAM J. Appl. Math. (14), 242–249
Birkhoff, G and Rota, G C, 1962, Ordinary Differential Equations, Ginn & Co., Boston and New York