e02aff computes the coefficients of a polynomial, in its Chebyshev series form, which interpolates (passes exactly through) data at a special set of points. Least squares polynomial approximations can also be obtained.
The routine may be called by the names e02aff or nagf_fit_dim1_cheb_glp.
3Description
e02aff computes the coefficients , for , in the Chebyshev series
which interpolates the data at the points
Here denotes the Chebyshev polynomial of the first kind of degree with argument . The use of these points minimizes the risk of unwanted fluctuations in the polynomial and is recommended when the data abscissae can be chosen by you, e.g., when the data is given as a graph. For further advantages of this choice of points, see Clenshaw (1962).
In terms of your original variables, say, the values of at which the data are to be provided are
where and are respectively the upper and lower ends of the range of over which you wish to interpolate.
Truncation of the resulting series after the term involving , say, yields a least squares approximation to the data. This approximation, , say, is the polynomial of degree which minimizes
where the residual , for .
The method employed is based on the application of the three-term recurrence relation due to Clenshaw (1955) for the evaluation of the defining expression for the Chebyshev coefficients (see, for example, Clenshaw (1962)). The modifications to this recurrence relation suggested by Reinsch and Gentleman (see Gentleman (1969)) are used to give greater numerical stability.
Subsequent evaluation of the computed polynomial, perhaps truncated after an appropriate number of terms, should be carried out using e02aef.
4References
Clenshaw C W (1955) A note on the summation of Chebyshev series Math. Tables Aids Comput.9 118–120
Clenshaw C W (1962) Chebyshev Series for Mathematical Functions Mathematical tables HMSO
Cox M G (1974) A data-fitting package for the non-specialist user Software for Numerical Mathematics (ed D J Evans) Academic Press
Cox M G and Hayes J G (1973) Curve fitting: a guide and suite of algorithms for the non-specialist user NPL Report NAC26 National Physical Laboratory
Gentleman W M (1969) An error analysis of Goertzel's (Watt's) method for computing Fourier coefficients Comput. J.12 160–165
5Arguments
1: – IntegerInput
On entry: the number of data points (one greater than the degree of the interpolating polynomial).
Constraint:
.
2: – Real (Kind=nag_wp) arrayInput
On entry: for , must contain the value of the dependent variable (ordinate) corresponding to the value
of the independent variable (abscissa) , or equivalently to the value
of your original variable . Here and are respectively the upper and lower ends of the range over which you wish to interpolate.
3: – Real (Kind=nag_wp) arrayOutput
On exit: is the coefficient in the interpolating polynomial, for .
4: – 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, .
Constraint: .
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
The rounding errors committed are such that the computed coefficients are exact for a slightly perturbed set of ordinates . The ratio of the sum of the absolute values of the to the sum of the absolute values of the is less than a small multiple of , where is the machine precision.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e02aff is not threaded in any implementation.
9Further Comments
The time taken is approximately proportional to .
For choice of degree when using the routine for least squares approximation, see Section 3.2 in the E02 Chapter Introduction.
10Example
Determine the Chebyshev coefficients of the polynomial which interpolates the data , for , where and . Evaluate, for comparison with the values of , the resulting Chebyshev series at , for .
The example program supplied is written in a general form that will enable polynomial interpolations of arbitrary data at the cosine points , for , to be obtained for any (). Note that e02aef is used to evaluate the interpolating polynomial. The program is self-starting in that any number of datasets can be supplied.