NAG Library Routine Document
e02akf
(dim1_cheb_eval2)
1
Purpose
e02akf evaluates a polynomial from its Chebyshev series representation, allowing an arbitrary index increment for accessing the array of coefficients.
2
Specification
Fortran Interface
Integer, Intent (In) | :: |
np1,
ia1,
la | Integer, Intent (Inout) | :: |
ifail | Real (Kind=nag_wp), Intent (In) | :: |
xmin,
xmax,
a(la),
x | Real (Kind=nag_wp), Intent (Out) | :: |
result |
|
C Header Interface
#include nagmk26.h
void |
e02akf_ (
const Integer *np1,
const double *xmin,
const double *xmax,
const double a[],
const Integer *ia1,
const Integer *la,
const double *x,
double *result,
Integer *ifail) |
|
3
Description
If supplied with the coefficients
, for
, of a polynomial
of degree
, where
e02akf returns the value of
at a user-specified value of the variable
. Here
denotes the Chebyshev polynomial of the first kind of degree
with argument
. It is assumed that the independent variable
in the interval
was obtained from your original variable
in the interval
by the linear transformation
The coefficients
may be supplied in the array
a, with any increment between the indices of array elements which contain successive coefficients. This enables the routine to be used in surface fitting and other applications, in which the array might have two or more dimensions.
The method employed is based on the three-term recurrence relation due to Clenshaw (see
Clenshaw (1955)), with modifications due to Reinsch and Gentleman (see
Gentleman (1969)). For further details of the algorithm and its use see
Cox (1973) 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 (1973) A data-fitting package for the non-specialist user NPL Report NAC 40 National Physical Laboratory
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: – IntegerInput
-
On entry: , where is the degree of the given polynomial .
Constraint:
.
- 2: – Real (Kind=nag_wp)Input
- 3: – Real (Kind=nag_wp)Input
-
On entry: the lower and upper end points respectively of the interval
. The Chebyshev series representation is in terms of the normalized variable
, where
Constraint:
.
- 4: – Real (Kind=nag_wp) arrayInput
-
On entry: the Chebyshev coefficients of the polynomial . Specifically, element
must contain the coefficient , for . Only these elements will be accessed.
- 5: – IntegerInput
-
On entry: the index increment of
a. Most frequently, the Chebyshev coefficients are stored in adjacent elements of
a, and
ia1 must be set to
. However, if, for example, they are stored in
, the value of
ia1 must be
.
Constraint:
.
- 6: – IntegerInput
-
On entry: the dimension of the array
a as declared in the (sub)program from which
e02akf is called.
Constraint:
.
- 7: – Real (Kind=nag_wp)Input
-
On entry: the argument at which the polynomial is to be evaluated.
Constraint:
.
- 8: – Real (Kind=nag_wp)Output
-
On exit: the value of the polynomial .
- 9: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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:
-
On entry, | , |
or | , |
or | , |
or | . |
-
x does not satisfy the restriction
.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The rounding errors 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
e02akf is not threaded in any implementation.
The time taken is approximately proportional to .
10
Example
Suppose a polynomial has been computed in Chebyshev series form to fit data over the interval
. The following program evaluates the polynomial at
equally spaced points over the interval. (For the purposes of this example,
xmin,
xmax and the Chebyshev coefficients are supplied
in DATA statements.
Normally a program would first read in or generate data and compute the fitted polynomial.)
10.1
Program Text
Program Text (e02akfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (e02akfe.r)