NAG FL Interface
e02aef (dim1_cheb_eval)
1
Purpose
e02aef evaluates a polynomial from its Chebyshev series representation.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
nplus1 |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
a(nplus1), xcap |
Real (Kind=nag_wp), Intent (Out) |
:: |
p |
|
C Header Interface
#include <nag.h>
void |
e02aef_ (const Integer *nplus1, const double a[], const double *xcap, double *p, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
e02aef_ (const Integer &nplus1, const double a[], const double &xcap, double &p, Integer &ifail) |
}
|
The routine may be called by the names e02aef or nagf_fit_dim1_cheb_eval.
3
Description
e02aef 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).
4
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
5
Arguments
-
1:
– Integer
Input
-
On entry: the number of terms in the series (i.e., one greater than the degree of the polynomial).
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to the value of the th coefficient in the series, for .
-
3:
– Real (Kind=nag_wp)
Input
-
On entry:
, 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
Section 6) to allow for possible rounding errors committed in the transformation from
to
discussed in
Section 3. Provided the recommended form of the transformation is used, a successful exit is thus assured whenever the value of
lies in the range
to
.
-
4:
– Real (Kind=nag_wp)
Output
-
On exit: the value of the polynomial.
-
5:
– Integer
Input/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).
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:
-
On entry, and .
Constraint: , where is machine precision.
-
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.
7
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 .
8
Parallelism and Performance
e02aef is not threaded in any implementation.
The time taken is approximately proportional to .
It is expected that a common use of
e02aef will be the evaluation of the polynomial approximations produced by
e02adf and
e02aff.
10
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.
10.1
Program Text
10.2
Program Data
10.3
Program Results