E02ADF determines least squares polynomial approximations of degrees to the set of data points with weights , for .
The approximation of degree has the property that it minimizes the sum of squares of the weighted residuals , where
and is the value of the polynomial of degree at the th data point.
Each polynomial is represented in Chebyshev series form with normalized argument . This argument lies in the range to and is related to the original variable by the linear transformation
Here and are respectively the largest and smallest values of . The polynomial approximation of degree is represented as
where , for , are the Chebyshev polynomials of the first kind of degree with argument .
For , the routine produces the values of , for , together with the value of the root-mean-square residual . In the case the routine sets the value of to zero.
The method employed is due to Forsythe (1957) and is based on the generation of a set of polynomials orthogonal with respect to summation over the normalized dataset. The extensions due to Clenshaw (1960) to represent these polynomials as well as the approximating polynomials in their Chebyshev series forms are incorporated. The modifications suggested by Reinsch and Gentleman (see Gentleman (1969)) to the method originally employed by Clenshaw for evaluating the orthogonal polynomials from their Chebyshev series representations are used to give greater numerical stability.
On exit: contains the root-mean-square residual , for , as described in Section 3. For the interpretation of the values of the and their use in selecting an appropriate degree, see Section 3.1 in the E02 Chapter Introduction.
11: 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).
Errors or warnings detected by the routine:
The weights are not all strictly positive.
The values of , for , are not in nondecreasing order.
All have the same value: thus the normalization of X is not possible.
(so the maximum degree required is negative)
, where is the number of distinct values in the data (so there cannot be a unique solution for degree ).
No error analysis for the method has been published. Practical experience with the method, however, is generally extremely satisfactory.
8 Further Comments
The time taken is approximately proportional to .
The approximating polynomials may exhibit undesirable oscillations (particularly near the ends of the range) if the maximum degree exceeds a critical value which depends on the number of data points and their relative positions. As a rough guide, for equally-spaced data, this critical value is about . For further details see page 60 of Hayes (1970).
Determine weighted least squares polynomial approximations of degrees , , and to a set of prescribed data points. For the approximation of degree , tabulate the data and the corresponding values of the approximating polynomial, together with the residual errors, and also the values of the approximating polynomial at points half-way between each pair of adjacent data points.
The example program supplied is written in a general form that will enable polynomial approximations of degrees to be obtained to data points, with arbitrary positive weights, and the approximation of degree to be tabulated. E02AEF is used to evaluate the approximating polynomial. The program is self-starting in that any number of datasets can be supplied.