PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_fit_1dcheb_eval (e02ae)
Purpose
nag_fit_1dcheb_eval (e02ae) evaluates a polynomial from its Chebyshev series representation.
Syntax
Description
nag_fit_1dcheb_eval (e02ae) evaluates the polynomial
for any value of
satisfying
. Here
denotes the Chebyshev polynomial of the first kind of degree
with argument
. The value of
is prescribed by you.
In practice, the variable
will usually have been obtained from an original variable
, where
and
Note that this form of the transformation should be used computationally rather than the mathematical equivalent
since the former guarantees that the computed value of
differs from its true value by at most
, where
is the
machine precision, whereas the latter has no such guarantee.
The method employed is based on the three-term recurrence relation due to
Clenshaw (1955), with modifications to give greater numerical stability due to Reinsch and Gentleman (see
Gentleman (1969)).
For further details of the algorithm and its use see
Cox (1974) and
Cox and Hayes (1973).
References
Clenshaw C W (1955) A note on the summation of Chebyshev series Math. Tables Aids Comput. 9 118–120
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
Parameters
Compulsory Input Parameters
- 1:
– double array
-
must be set to the value of the th coefficient in the series, for .
- 2:
– double scalar
-
, the argument at which the polynomial is to be evaluated. It should lie in the range
to
, but a value just outside this range is permitted (see
Error Indicators and Warnings) to allow for possible rounding errors committed in the transformation from
to
discussed in
Description. Provided the recommended form of the transformation is used, a successful exit is thus assured whenever the value of
lies in the range
to
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
a.
The number of terms in the series (i.e., one greater than the degree of the polynomial).
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The value of the polynomial.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
, where
is the
machine precision. In this case the value of
p is set arbitrarily to zero.
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The rounding errors committed are such that the computed value of the polynomial is exact for a slightly perturbed set of coefficients . 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 .
Further Comments
The time taken is approximately proportional to .
It is expected that a common use of
nag_fit_1dcheb_eval (e02ae) will be the evaluation of the polynomial approximations produced by
nag_fit_1dcheb_arb (e02ad) and
nag_fit_1dcheb_glp (e02af).
Example
Evaluate at equally-spaced points in the interval the polynomial of degree with Chebyshev coefficients, , , , , .
The example program is written in a general form that will enable a polynomial of degree in its Chebyshev series form to be evaluated at equally-spaced points in the interval . The program is self-starting in that any number of datasets can be supplied.
Open in the MATLAB editor:
e02ae_example
function e02ae_example
fprintf('e02ae example results\n\n');
a = [2 0.5 0.25 0.125 0.0625];
xcap = [-1:0.2:1]';
for i=1:11
[p(i), ifail] = e02ae(a, xcap(i));
end
disp(' x p(x)');
disp([xcap p']);
e02ae example results
x p(x)
-1.0000 0.6875
-0.8000 0.6613
-0.6000 0.6943
-0.4000 0.7433
-0.2000 0.7843
0 0.8125
0.2000 0.8423
0.4000 0.9073
0.6000 1.0603
0.8000 1.3733
1.0000 1.9375
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015