N, M(N), L(N), K1, KP, LDC, LW, IW(LIW), LIW, IFAIL
X0, X1, C(LDC,N), W(LW)
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 (see Section 9 for an example). E02AHF and E02AJF may be used to obtain Chebyshev series representations of derivatives and integrals (respectively) of the components of the solution.
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
1: N – INTEGERInput
On entry: , the number of differential equations in the system.
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: LDC – INTEGERInput
On entry: the first dimension of the array C as declared in the (sub)program from which D02TGF is called.
10: COEFF – 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: RHS – 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. Parameters denoted as Input must not be changed by this procedure.
11: BDYC – 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 dimension of the array IW as declared in the (sub)program from which D02TGF is called.
16: IFAIL – 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).
Either the boundary conditions are not linearly independent, 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). Increasing KP may remove this difficulty.
Estimates of the accuracy of the solution may be obtained by using the checks described in Section 8. The Chebyshev coefficients are calculated by a stable numerical method.
8 Further 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. In the example in Section 9, the variables are to be determined at the current iteration whilst the variables correspond to the solution determined at the previous iteration, (or the initial approximation on the first iteration). 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 E02ADF or E02AFF to obtain a Chebyshev series for an approximate solution. The coefficients of the current iterate must be communicated to COEFF and BDYC, e.g., in COMMON. (See Section 9.) The convergence of the (Newton) iteration cannot be guaranteed in general, though it is usually satisfactory from a good starting approximation.
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.