D02JAF calculates the solution of a regular two-point boundary value problem for a single th-order linear ordinary differential equation 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, one equation 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 of the differential equation on an interval normalized to .
E02AKF can be used to evaluate the solution at any point on the interval – see Section 9 for an example. E02AHF followed by E02AKF can be used to evaluate its derivatives.
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 order of the differential equation.
2: CF – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
CF defines the differential equation (see Section 3). It must return the value of a function at a given point , where, for , is the coefficient of in the equation, and is the right-hand side.
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:
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).
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 polynomial and the number of collocation points (see Section 8).
8 Further Comments
The time taken by D02JAF depends on the complexity of the differential equation, 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 (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 .
Systems of regular linear differential equations can be solved using D02JBF. It is necessary before using D02JBF to write the differential equations as a first-order system. Linear systems of high-order equations in their original form, singular problems, and, indirectly, nonlinear problems can be solved using D02TGF.
This example solves the equation
with boundary conditions
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 .