|
NAG[e02adc] NAG[nag_1d_cheb_fit] - Computes the coefficients of a Chebyshev series polynomial for arbitrary data
|
|
Calling Sequence
e02adc(x, y, w, a, s, 'm'=m, 'kplus1'=kplus1, 'tda'=tda, 'fail'=fail)
nag_1d_cheb_fit(. . .)
Parameters
|
x - Vector(1..m, datatype=float[8]);
|
|
|
On entry: the values of the independent variable, for .
|
|
Constraint: the values must be supplied in non-decreasing order with . .
|
|
|
y - Vector(1..m, datatype=float[8]);
|
|
|
On entry: the values of the dependent variable, for .
|
|
|
w - Vector(1..m, datatype=float[8]);
|
|
|
On entry: the set of weights, , for . For advice on the choice of weights, see the the e02 Chapter Introduction.
|
|
Constraint: , for . .
|
|
|
a - Matrix(1..kplus1, 1..tda, datatype=float[8], order=C_order);
|
|
|
|
s - Vector(1..kplus1, datatype=float[8]);
|
|
|
|
'm'=m - integer; (optional)
|
|
|
Default value: the first dimension of the arrays x, y, w.
|
|
On entry: the number of data points.
|
|
|
'kplus1'=kplus1 - integer; (optional)
|
|
|
Default value: the first dimension of the arrays a, s and the second dimension of the arrays a, sthe array a.
|
|
On entry: , where is the maximum degree required.
|
|
|
'tda'=tda - integer; (optional)
|
|
|
On entry: the second dimension of the array a as declared in the function from which nag_1d_cheb_fit (e02adc) is called.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_1d_cheb_fit (e02adc) computes weighted least-squares polynomial approximations to an arbitrary set of data points.
|
|
Error Indicators and Warnings
|
|
"NE_2_INT_ARG_GT"
On entry, while the number of distinct values, . These arguments must satisfy .
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_INT_ARG_LT"
On entry, kplus1 must not be less than 1: .
"NE_NO_NORMALISATION"
On entry, all the in the sequence , are the same.
"NE_NOT_NON_DECREASING"
On entry, the sequence , is not in non-decreasing order.
"NE_WEIGHTS_NOT_POSITIVE"
On entry, the weights are not strictly positive: .
|
|
Accuracy
|
|
No error analysis for the method has been published. Practical experience with the method, however, is generally extremely satisfactory.
|
|
Further Comments
|
|
The time taken by nag_1d_cheb_fit (e02adc) 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).
|
|
|
Examples
|
|
>
|
m := 11:
kplus1 := 4:
tda := 4:
x := Vector([1, 2.1, 3.1, 3.9, 4.9, 5.8, 6.5, 7.1, 7.8, 8.4, 9], datatype=float[8]):
y := Vector([10.4, 7.9, 4.7, 2.5, 1.2, 2.2, 5.1, 9.199999999999999, 16.1, 24.5, 35.3], datatype=float[8]):
w := Vector([1, 1, 1, 1, 1, 0.8, 0.8, 0.7, 0.5, 0.3, 0.2], datatype=float[8]):
a := Matrix(4, 4, datatype=float[8], order='C_order'):
s := Vector(4, datatype=float[8]):
NAG:-e02adc(x, y, w, a, s, 'm' = m, 'kplus1' = kplus1, 'tda' = tda):
|
|
|
See Also
|
|
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
e02 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|