# NAG FL Interfacec06dcf (chebyshev)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine c06dcf ( x, lx, xmin, xmax, c, n, s, res,
 Integer, Intent (In) :: lx, n, s Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x(lx), xmin, xmax, c(n) Real (Kind=nag_wp), Intent (Out) :: res(lx)
#include <nag.h>
 void c06dcf_ (const double x[], const Integer *lx, const double *xmin, const double *xmax, const double c[], const Integer *n, const Integer *s, double res[], Integer *ifail)
The routine may be called by the names c06dcf or nagf_sum_chebyshev.

## 3Description

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(\overline{x}\right)$ ${\mathbf{s}}=2$: $0.5{c}_{1}+\sum _{\mathit{j}=2}^{n}{c}_{j}{T}_{2j-2}\left(\overline{x}\right)$ ${\mathbf{s}}=3$: $\sum _{\mathit{j}=1}^{n}{c}_{j}{T}_{2j-1}\left(\overline{x}\right)$
where $\overline{x}$ lies in the range $-1.0\le \overline{x}\le 1.0$. Here ${T}_{r}\left(x\right)$ is the Chebyshev polynomial of order $r$ in $\overline{x}$, defined by $\mathrm{cos}\left(ry\right)$ where $\mathrm{cos}y=\overline{x}$.
It is assumed that the independent variable $\overline{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.
Clenshaw C W (1962) Chebyshev Series for Mathematical Functions Mathematical tables HMSO

## 5Arguments

1: $\mathbf{x}\left({\mathbf{lx}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{lx}$Integer Input
On entry: the number of evaluation points in $X$.
Constraint: ${\mathbf{lx}}\ge 1$.
3: $\mathbf{xmin}$Real (Kind=nag_wp) Input
4: $\mathbf{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 $\overline{x}$, where
 $x¯ = 2x-(xmax+xmin) xmax-xmin .$
Constraint: ${\mathbf{xmin}}<{\mathbf{xmax}}$.
5: $\mathbf{c}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{n}$Integer Input
On entry: $n$, the number of terms in the series.
Constraint: ${\mathbf{n}}\ge 1$.
7: $\mathbf{s}$Integer Input
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: $\mathbf{res}\left({\mathbf{lx}}\right)$Real (Kind=nag_wp) array Output
On exit: the Chebyshev series evaluated at the set of points $X$.
9: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-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 $-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 $-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 $-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{lx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lx}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{s}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{s}}=1$, $2$ or $3$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{xmax}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{xmin}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{xmin}}<{\mathbf{xmax}}$.
${\mathbf{ifail}}=5$
On entry, element ${\mathbf{x}}\left(⟨\mathit{\text{value}}⟩\right)=⟨\mathit{\text{value}}⟩$, ${\mathbf{xmin}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{xmax}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{xmin}}\le {\mathbf{x}}\left(i\right)\le {\mathbf{xmax}}$, for all $i$.
${\mathbf{ifail}}=-99$
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

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.

## 8Parallelism and Performance

c06dcf is not threaded in any implementation.

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.

## 10Example

This example evaluates
 $0.5+ T1(x)+ 0.5T2(x)+ 0.25T3(x)$
at the points $X=\left[0.5,1.0,-0.2\right]$.

### 10.1Program Text

Program Text (c06dcfe.f90)

### 10.2Program Data

Program Data (c06dcfe.d)

### 10.3Program Results

Program Results (c06dcfe.r)