The routine may be called by the names e02adf or nagf_fit_dim1_cheb_arb.
3Description
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.
Subsequent evaluation of the Chebyshev series representations of the polynomial approximations should be carried out using e02aef.
4References
Clenshaw C W (1960) Curve fitting with a digital computer Comput. J.2 170–173
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
Forsythe G E (1957) Generation and use of orthogonal polynomials for data fitting with a digital computer J. Soc. Indust. Appl. Math.5 74–88
Gentleman W M (1969) An error analysis of Goertzel's (Watt's) method for computing Fourier coefficients Comput. J.12 160–165
Hayes J G (ed.) (1970) Numerical Approximation to Functions and Data Athlone Press, London
5Arguments
1: – IntegerInput
On entry: the number of data points.
Constraint:
, where is the number of distinct values in the data.
2: – IntegerInput
On entry: , where is the maximum degree required.
Constraint:
, where is the number of distinct values in the data.
3: – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which e02adf is called.
Constraint:
.
4: – Real (Kind=nag_wp) arrayInput
On entry: the values
of the independent variable, for .
Constraint:
the values must be supplied in nondecreasing order with .
5: – Real (Kind=nag_wp) arrayInput
On entry: the values
of the dependent variable, for .
6: – Real (Kind=nag_wp) arrayInput
On entry: the set of weights,
, for . For advice on the choice of weights, see Section 2.1.2 in the E02 Chapter Introduction.
Constraint:
, for .
7: – Real (Kind=nag_wp) arrayWorkspace
8: – Real (Kind=nag_wp) arrayWorkspace
9: – Real (Kind=nag_wp) arrayOutput
On exit: the coefficients of
in the approximating polynomial of degree . contains the coefficient , for and .
10: – Real (Kind=nag_wp) arrayOutput
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: – 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, and .
Constraint: .
On entry, , and .
Constraint: .
On entry, all have the same value: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: , where mdist is the number of distinct x values.
On entry, and .
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
No error analysis for the method has been published. Practical experience with the method, however, is generally extremely satisfactory.
8Parallelism and Performance
e02adf is not threaded in any implementation.
9Further 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).
10Example
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.