The routine may be called by the names d02tgf or nagf_ode_bvp_coll_nth_comp.
3Description
d02tgf calculates an approximate solution of a linear or linearized system of ordinary differential equations as a Chebyshev series. Suppose there are differential equations for variables , over the range . Let the th equation be
where . coeff evaluates the coefficients and the right-hand side for each , , at any point . The boundary conditions may be applied either at the end points or at intermediate points; they are written in the same form as the differential equations, and specified by bdyc. For example the th boundary condition out of those associated with the th differential equation takes the form
where lies between and . It is assumed in this routine that certain of the boundary conditions are associated with each differential equation. This is for your convenience; the grouping does not affect the results.
The degree of the polynomial solution must be the same for all variables. You specify the degree required, , and the number of collocation points, , in the range. The routine sets up a system of linear equations for the Chebyshev coefficients, with equations for each collocation point and one for each boundary condition. The collocation points are chosen at the extrema of a shifted Chebyshev polynomial of degree . The boundary conditions are satisfied exactly, and the remaining equations are solved by a least squares method. The result produced is a set of Chebyshev coefficients for the functions , with the range normalized to .
e02akf can be used to evaluate the components of the solution at any point on the range . e02ahfande02ajf may be used to obtain Chebyshev series representations of derivatives and integrals (respectively) of the components of the solution.
4References
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
5Arguments
1: – IntegerInput
On entry: , the number of differential equations in the system.
Constraint:
.
2: – Integer arrayInput
On entry: must be set to the highest order derivative occurring in the th equation, for .
Constraint:
, for .
3: – Integer arrayInput
On entry: must be set to the number of boundary conditions associated with the th equation, for .
Constraint:
, for .
4: – Real (Kind=nag_wp)Input
On entry: the left-hand boundary, .
5: – Real (Kind=nag_wp)Input
On entry: the right-hand boundary, .
Constraint:
.
6: – IntegerInput
On entry: the number of coefficients, , to be returned in the Chebyshev series representation 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 th column of c contains the computed Chebyshev coefficients of the th component of the solution, ; that is, the computed solution is:
where is the 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 d02tgf is called.
Constraint:
.
10: – Subroutine, supplied by the user.External Procedure
coeff defines the system of differential equations (see Section 3). It must evaluate the coefficient functions and the right-hand side function of the th equation at a given point. Only nonzero entries of the array a and rhs need be specifically assigned, since all elements are set to zero by d02tgf before calling coeff.
On entry: the first dimension of the array a and the second dimension of the array a as declared in the (sub)program from which d02tgf is called.
6: – Real (Kind=nag_wp)Input/Output
On entry: is set to zero.
On exit: it must contain the value .
coeff must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tgf is called. Arguments denoted as Input must not be changed by this procedure.
Note:coeff should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tgf. If your code inadvertently does return any NaNs or infinities, d02tgf is likely to produce unexpected results.
11: – Subroutine, supplied by the user.External Procedure
bdyc defines the boundary conditions (see Section 3). It must evaluate the coefficient functions and right-hand side function in the th boundary condition associated with the th equation, at the point at which the boundary condition is applied. Only nonzero entries of the array a and rhs need be specifically assigned, since all elements are set to zero by d02tgf before calling bdyc.
On entry: the first dimension of the array a and the second dimension of the array a as declared in the (sub)program from which d02tgf is called.
7: – Real (Kind=nag_wp)Input/Output
On entry: is set to zero.
On exit: the value .
bdyc must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which d02tgf is called. Arguments denoted as Input must not be changed by this procedure.
Note:bdyc should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02tgf. If your code inadvertently does return any NaNs or infinities, d02tgf is likely to produce unexpected results.
12: – Real (Kind=nag_wp) arrayWorkspace
13: – IntegerInput
On entry: the dimension of the array w as declared in the (sub)program from which d02tgf is called.
Constraint:
, where .
14: – Integer arrayWorkspace
15: – IntegerInput
On entry: the dimension of the array iw as declared in the (sub)program from which d02tgf is called.
Constraint:
.
16: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or 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).
6Error 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, a negative number of boundary conditions was set for one of the system equations.
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, one of the equations is of order less than .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
Either the boundary conditions are not linearly independent, or the coefficient matrix is rank deficient. Increasing the number of collocation points may overcome this latter problem.
Iterative refinement in the least squares solution has failed to converge. The coefficient matrix is too ill-conditioned.
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
Estimates of the accuracy of the solution may be obtained by using the checks described in Section 9. The Chebyshev coefficients are calculated by a stable numerical method.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
d02tgf 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.
9Further Comments
The time taken by d02tgf depends on the complexity of the system of differential equations, the degree of the polynomial solution and the number of matching points.
If the number of matching points is equal to the number of coefficients minus the average number of boundary conditions
, then the least squares solution reduces to simple solution of linear equations and true collocation results. The accuracy of the solution may be checked by repeating the calculation with different values of . If the Chebyshev coefficients decrease rapidly, the size of the last two or three gives an indication of the error. If they do not decrease rapidly, it may be desirable to use a different method. Note that the Chebyshev coefficients are calculated for the range normalized to .
Generally the number of boundary conditions required is equal to the sum of the orders of the differential equations. However, in some cases fewer boundary conditions are needed, because the assumption of a polynomial solution is equivalent to one or more boundary conditions (since it excludes singular solutions).
A system of nonlinear differential equations must be linearized before using the routine. The calculation is repeated iteratively. On each iteration the linearized equation is used. For a starting approximation, we may take, say, a linear function, and set up the appropriate Chebyshev coefficients before starting the iteration. For example, if in the range , we set , the array of coefficients,
,
,
and the remainder of the entries to zero.
In some cases a better initial approximation may be needed and can be obtained by using e02adfore02aff to obtain a Chebyshev series for an approximate solution. The coefficients of the current iterate must be communicated to coeff and bdyc, for example using global variables. The convergence of the (Newton) iteration cannot be guaranteed in general, though it is usually satisfactory from a good starting approximation.
10Example
This example solves the nonlinear system
in the range , with , , at .
Suppose an approximate solution is , such that , : then the first equation gives, on linearizing,
The starting approximation is taken to be , . In the program below, the array is used to hold the coefficients of the previous iterate (or of the starting approximation). We iterate until the Chebyshev coefficients converge to five figures. e02akf is used to calculate the solution from its Chebyshev coefficients.