C06 Chapter Contents
C06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentC06DCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

C06DCF evaluates a polynomial from its Chebyshev series representation at a set of points.

## 2  Specification

 SUBROUTINE C06DCF ( X, LX, XMIN, XMAX, C, N, S, RES, IFAIL)
 INTEGER LX, N, S, IFAIL REAL (KIND=nag_wp) X(LX), XMIN, XMAX, C(N), RES(LX)

## 3  Description

C06DCF evaluates, at each point in a given set $X$, the sum of a Chebyshev series of one of three forms according to the value of the parameter S:
 ${\mathbf{S}}=1$: $0.5{c}_{1}+\sum _{\mathit{j}=2}^{n}{c}_{j}{T}_{j-1}\left(\stackrel{-}{x}\right)$ ${\mathbf{S}}=2$: $0.5{c}_{1}+\sum _{\mathit{j}=2}^{n}{c}_{j}{T}_{2j-2}\left(\stackrel{-}{x}\right)$ ${\mathbf{S}}=3$: $\sum _{\mathit{j}=1}^{n}{c}_{j}{T}_{2j-1}\left(\stackrel{-}{x}\right)$
where $\stackrel{-}{x}$ lies in the range $-1.0\le \stackrel{-}{x}\le 1.0$. Here ${T}_{r}\left(x\right)$ is the Chebyshev polynomial of order $r$ in $\stackrel{-}{x}$, defined by $\mathrm{cos}\left(ry\right)$ where $\mathrm{cos}y=\stackrel{-}{x}$.
It is assumed that the independent variable $\stackrel{-}{x}$ in the interval $\left[-1.0,+1.0\right]$ was obtained from your original variable $x\in X$, a set of real numbers in the interval $\left[{x}_{\mathrm{min}},{x}_{\mathrm{max}}\right]$, by the linear transformation
 $x- = 2x-xmax+xmin xmax-xmin .$
The method used is based upon a three-term recurrence relation; for details see Clenshaw (1962).
The coefficients ${c}_{j}$ are normally generated by other routines, for example they may be those returned by the interpolation routine E01AEF (in vector A), by a least squares fitting routine in Chapter E02, or as the solution of a boundary value problem by D02JAF, D02JBF or D02UEF.

## 4  References

Clenshaw C W (1962) Chebyshev Series for Mathematical Functions Mathematical tables HMSO

## 5  Parameters

1:     X(LX) – REAL (KIND=nag_wp) arrayInput
On entry: $x\in X$, the set of arguments of the series.
Constraint: ${\mathbf{XMIN}}\le {\mathbf{X}}\left(\mathit{i}\right)\le {\mathbf{XMAX}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{LX}}$.
2:     LX – INTEGERInput
On entry: the number of evaluation points in $X$.
Constraint: ${\mathbf{LX}}\ge 1$.
3:     XMIN – REAL (KIND=nag_wp)Input
4:     XMAX – REAL (KIND=nag_wp)Input
On entry: the lower and upper end points respectively of the interval $\left[{x}_{\mathrm{min}},{x}_{\mathrm{max}}\right]$. The Chebyshev series representation is in terms of the normalized variable $\stackrel{-}{x}$, where
 $x- = 2x-xmax+xmin xmax-xmin .$
Constraint: ${\mathbf{XMIN}}<{\mathbf{XMAX}}$.
5:     C(N) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{C}}\left(\mathit{j}\right)$ must contain the coefficient ${c}_{\mathit{j}}$ of the Chebyshev series, for $\mathit{j}=1,2,\dots ,n$.
6:     N – INTEGERInput
On entry: $n$, the number of terms in the series.
Constraint: ${\mathbf{N}}\ge 1$.
7:     S – INTEGERInput
On entry: determines the series (see Section 3).
${\mathbf{S}}=1$
The series is general.
${\mathbf{S}}=2$
The series is even.
${\mathbf{S}}=3$
The series is odd.
Constraint: ${\mathbf{S}}=1$, $2$ or $3$.
8:     RES(LX) – REAL (KIND=nag_wp) arrayOutput
On exit: the Chebyshev series evaluated at the set of points $X$.
9:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

${\mathbf{IFAIL}}=1$
On entry, ${\mathbf{LX}}<1$.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{N}}<1$.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{S}}\ne 1$, $2$ or $3$.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{XMAX}}\le {\mathbf{XMIN}}$.
${\mathbf{IFAIL}}=5$
On entry, an element of X is less than XMIN or greater than XMAX.

## 7  Accuracy

There may be a loss of significant figures due to cancellation between terms. However, provided that $n$ is not too large, C06DCF yields results which differ little from the best attainable for the available machine precision.

The time taken increases with $n$.
C06DCF has been prepared in the present form to complement a number of integral equation solving routines which use Chebyshev series methods, e.g., D05AAF and D05ABF.

## 9  Example

This example evaluates
 $0.5+ T1x+ 0.5T2x+ 0.25T3x$
at the points $X=\left[0.5,1.0,-0.2\right]$.

### 9.1  Program Text

Program Text (c06dcfe.f90)

### 9.2  Program Data

Program Data (c06dcfe.d)

### 9.3  Program Results

Program Results (c06dcfe.r)