d02 Chapter Contents
d02 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_ode_bvp_ps_lin_cheb_eval (d02uzc)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_ode_bvp_ps_lin_cheb_eval (Integer k, double x, double *t, NagError *fail)

## 3  Description

nag_ode_bvp_ps_lin_cheb_eval (d02uzc) 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  Arguments

1:     kIntegerInput
On entry: the order of the Chebyshev polynomial.
Constraint: ${\mathbf{k}}\ge 0$.
2:     xdoubleInput
On entry: the point at which to evaluate the polynomial.
Constraint: $-1.0\le {\mathbf{x}}\le 1.0$.
3:     tdouble *Output
On exit: the value, $T$, of the Chebyshev polynomial order $k$ evaluated at $x$.
4:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: $-1.0\le {\mathbf{x}}\le 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 nag_ode_bvp_ps_lin_cgl_grid (d02ucc). At each of a set of new grid points in the domain of the function nag_ode_bvp_ps_lin_cheb_eval (d02uzc) 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 (d02uzce.c)

### 9.2  Program Data

Program Data (d02uzce.d)

### 9.3  Program Results

Program Results (d02uzce.r)