D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentD02UZF

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

D02UZF returns the value of the $k$th Chebyshev polynomial evaluated at a point $x\in \left[-1,1\right]$. D02UZF is primarily a utility routine for use by the Chebyshev boundary value problem solvers.

2  Specification

 SUBROUTINE D02UZF ( K, X, T, IFAIL)
 INTEGER K, IFAIL REAL (KIND=nag_wp) X, T

3  Description

D02UZF returns the value, $T$, of the $k$th Chebyshev polynomial evaluated at a point $x\in \left[-1,1\right]$; that is, $T=\mathrm{cos}\left(k×\mathrm{arccos}\left(x\right)\right)$.

4  References

Trefethen L N (2000) Spectral Methods in MATLAB SIAM

5  Parameters

1:     K – INTEGERInput
On entry: the order of the Chebyshev polynomial.
Constraint: ${\mathbf{K}}\ge 0$.
2:     X – REAL (KIND=nag_wp)Input
On entry: the point at which to evaluate the polynomial.
Constraint: $-1.0\le {\mathbf{X}}\le 1.0$.
3:     T – REAL (KIND=nag_wp)Output
On exit: the value, $T$, of the Chebyshev polynomial order $k$ evaluated at $x$.
4:     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{K}}<0$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{X}}<-1.0$ or ${\mathbf{X}}>1.0$.

7  Accuracy

The accuracy should be close to machine precision.

None.

9  Example

A set of Chebyshev coefficients is obtained for the function $x+\mathrm{exp}\left(-x\right)$ defined on $\left[-0.24×\pi ,0.5×\pi \right]$ using D02UCF. At each of a set of new grid points in the domain of the function D02UZF is used to evaluate each Chebshev polynomial in the series representation. The values obtained are multiplied to the Chebyshev coefficients and summed to obtain approximations to the given function at the new grid points.

9.1  Program Text

Program Text (d02uzfe.f90)

9.2  Program Data

Program Data (d02uzfe.d)

9.3  Program Results

Program Results (d02uzfe.r)