for any value of $\overline{x}$ satisfying $\mathrm{-1}\le \overline{x}\le 1$. Here ${T}_{j}\left(\overline{x}\right)$ denotes the Chebyshev polynomial of the first kind of degree $j$ with argument $\overline{x}$. The value of $n$ is prescribed by you.
In practice, the variable $\overline{x}$ will usually have been obtained from an original variable $x$, where ${x}_{\mathrm{min}}\le x\le {x}_{\mathrm{max}}$ and
since the former guarantees that the computed value of $\overline{x}$ differs from its true value by at most $4\epsilon $, where $\epsilon $ 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)).
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
5Arguments
1: $\mathbf{nplus1}$ – IntegerInput
On entry: the number $n+1$ of terms in the series (i.e., one greater than the degree of the polynomial).
Constraint:
${\mathbf{nplus1}}\ge 1$.
2: $\mathbf{a}\left({\mathbf{nplus1}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: ${\mathbf{a}}\left(\mathit{i}\right)$ must be set to the value of the $\mathit{i}$th coefficient in the series, for $\mathit{i}=1,2,\dots ,n+1$.
3: $\mathbf{xcap}$ – Real (Kind=nag_wp)Input
On entry: $\overline{x}$, the argument at which the polynomial is to be evaluated. It should lie in the range $\mathrm{-1}$ to $+1$, but a value just outside this range is permitted (see Section 6) to allow for possible rounding errors committed in the transformation from $x$ to $\overline{x}$ discussed in Section 3. Provided the recommended form of the transformation is used, a successful exit is thus assured whenever the value of $x$ lies in the range ${x}_{\mathrm{min}}$ to ${x}_{\mathrm{max}}$.
4: $\mathbf{p}$ – Real (Kind=nag_wp)Output
On exit: the value of the polynomial.
5: $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $\mathrm{-1}$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $\mathrm{-1}$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry ${\mathbf{ifail}}=0$ or $\mathrm{-1}$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{xcap}}=\u27e8\mathit{\text{value}}\u27e9$ and $\mathrm{EPS}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: $\left|{\mathbf{xcap}}\right|\le 1+4\times \mathrm{EPS}$, where $\mathrm{EPS}$ is machine precision.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{nplus1}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nplus1}}\ge 1$.
${\mathbf{ifail}}=-99$
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.
${\mathbf{ifail}}=-399$
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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The rounding errors committed are such that the computed value of the polynomial is exact for a slightly perturbed set of coefficients ${a}_{i}+\delta {a}_{i}$. The ratio of the sum of the absolute values of the $\delta {a}_{i}$ to the sum of the absolute values of the ${a}_{i}$ is less than a small multiple of $(n+1)\times \mathit{machineprecision}$.
8Parallelism and Performance
e02aef is not threaded in any implementation.
9Further Comments
The time taken is approximately proportional to $n+1$.
It is expected that a common use of e02aef will be the evaluation of the polynomial approximations produced by e02adfande02aff.
10Example
Evaluate at $11$ equally-spaced points in the interval $\mathrm{-1}\le \overline{x}\le 1$ the polynomial of degree $4$ with Chebyshev coefficients, $2.0$, $0.5$, $0.25$, $0.125$, $0.0625$.
The example program is written in a general form that will enable a polynomial of degree $n$ in its Chebyshev series form to be evaluated at $m$ equally-spaced points in the interval $\mathrm{-1}\le \overline{x}\le 1$. The program is self-starting in that any number of datasets can be supplied.