NAG Library Routine Document
D02JBF
1 Purpose
D02JBF solves a regular linear two-point boundary value problem for a system of ordinary differential equations by Chebyshev series using collocation and least squares.
2 Specification
SUBROUTINE D02JBF ( |
N, CF, BC, X0, X1, K1, KP, C, LDC, W, LW, IW, LIW, IFAIL) |
INTEGER |
N, K1, KP, LDC, LW, IW(LIW), LIW, IFAIL |
REAL (KIND=nag_wp) |
CF, X0, X1, C(LDC,N), W(LW) |
EXTERNAL |
CF, BC |
|
3 Description
D02JBF calculates the solution of a regular two-point boundary value problem for a regular linear
th-order system of first-order ordinary differential equations as a Chebyshev series in the interval
. The differential equation
is defined by
CF, and the boundary conditions at the points
and
are defined by
BC.
You specify the degree of Chebyshev series required,
, and the number of collocation points,
KP. The routine sets up a system of linear equations for the Chebyshev coefficients,
equations for each collocation point and one for each boundary condition. The boundary conditions are solved exactly, and the remaining equations are then solved by a least squares method. The result produced is a set of coefficients for a Chebyshev series solution for each component of the solution of the system of differential equations on an interval normalized to
.
E02AKF can be used to evaluate the components of the solution at any point on the interval
– see
Section 10 for an example.
E02AHF followed by
E02AKF can be used to evaluate their derivatives.
4 References
Picken S M (1970) Algorithms for the solution of differential equations in Chebyshev-series by the selected points method Report Math. 94 National Physical Laboratory
5 Parameters
- 1: – INTEGERInput
-
On entry: , the order of the system of differential equations.
Constraint:
.
- 2: – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
-
CF defines the system of differential equations (see
Section 3). It must return the value of a coefficient function
, of
, at a given point
, or of a right-hand side function
if
.
The specification of
CF is:
INTEGER |
I, J |
REAL (KIND=nag_wp) |
X |
|
- 1: – INTEGERInput
- 2: – INTEGERInput
-
On entry: indicate the function to be evaluated, namely if , or if .
, .
- 3: – REAL (KIND=nag_wp)Input
-
On entry: the point at which the function is to be evaluated.
CF must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02JBF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 3: – SUBROUTINE, supplied by the user.External Procedure
-
BC defines the
boundary conditions, which have the form
or
. The boundary conditions may be specified in any order.
The specification of
BC is:
SUBROUTINE BC ( |
I, J, RHS) |
INTEGER |
I, J |
REAL (KIND=nag_wp) |
RHS |
|
- 1: – INTEGERInput
-
On entry: the index of the boundary condition to be defined.
- 2: – INTEGEROutput
-
On exit: must be set to
if the
th boundary condition is
, or to
if it is
.
J must not be set to the same value
for two different values of
I.
- 3: – REAL (KIND=nag_wp)Output
-
On exit: the value .
BC must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02JBF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 4: – REAL (KIND=nag_wp)Input
- 5: – REAL (KIND=nag_wp)Input
-
On entry: the left- and right-hand boundaries, and , respectively.
Constraint:
.
- 6: – INTEGERInput
-
On entry: the number of coefficients to be returned in the Chebyshev series representation of the components of the solution (hence the degree of the polynomial approximation is ).
Constraint:
.
- 7: – INTEGERInput
-
On entry: the number of collocation points to be used.
Constraint:
.
- 8: – REAL (KIND=nag_wp) arrayOutput
-
On exit: the computed Chebyshev coefficients of the
th component of the solution,
; that is, the computed solution is:
where
is the
th Chebyshev polynomial of the first kind, and
denotes that the first coefficient,
, is halved.
- 9: – INTEGERInput
-
On entry: the first dimension of the array
C as declared in the (sub)program from which D02JBF is called.
Constraint:
.
- 10: – REAL (KIND=nag_wp) arrayWorkspace
- 11: – INTEGERInput
-
On entry: the dimension of the array
W as declared in the (sub)program from which D02JBF is called.
Constraint:
.
- 12: – INTEGER arrayWorkspace
- 13: – INTEGERInput
-
On entry: the dimension of the array
IW as declared in the (sub)program from which D02JBF is called.
Constraint:
.
- 14: – 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:
-
On entry, | , |
or | , |
or | , |
or | , |
or | . |
-
On entry, | , |
or | (i.e., insufficient workspace). |
-
Either the boundary conditions are not linearly independent (that is, in
BC the variable
J is set to the same value
for two different values of
I), or the rank of the matrix of equations for the coefficients is less than the number of unknowns. Increasing
KP may overcome this latter problem.
-
The least squares routine
F04AMF has failed to correct the first approximate solution (see
F04AMF).
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.
7 Accuracy
The Chebyshev coefficients are determined by a stable numerical method. The accuracy of the approximate solution may be checked by varying the degree of the polynomials and the number of collocation points (see
Section 9).
8 Parallelism and Performance
D02JBF is not threaded by NAG in any implementation.
D02JBF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken by D02JBF depends on the size and complexity of the differential system, the degree of the polynomial solution, and the number of matching points.
The collocation points in the interval are chosen to be the extrema of the appropriate shifted Chebyshev polynomial. If , then the least squares solution reduces to the solution of a system of linear equations, and true collocation results.
The accuracy of the solution may be checked by repeating the calculation with different values of
K1 and with
KP fixed but
. If the Chebyshev coefficients decrease rapidly for each component (and consistently for various
K1 and
KP), the size of the last two or three gives an indication of the error. If the Chebyshev coefficients do not decay rapidly, it is likely that the solution cannot be well-represented by Chebyshev series. Note that the Chebyshev coefficients are calculated for the interval
.
Linear systems of high-order equations in their original form, singular problems, and, indirectly, nonlinear problems can be solved using
D02TGF.
10 Example
This example solves the equation
with boundary conditions
The equation is written as the first-order system
for solution by D02JBF and the boundary conditions are written
We use
,
and
, and
and
, so that the different Chebyshev series may be compared. The solution for
and
is evaluated by
E02AKF at nine equally spaced points over the interval
.
10.1 Program Text
Program Text (d02jbfe.f90)
10.2 Program Data
Program Data (d02jbfe.d)
10.3 Program Results
Program Results (d02jbfe.r)