NAG CL Interface
c06dcc (chebyshev)

Settings help

CL Name Style:


1 Purpose

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

2 Specification

#include <nag.h>
void  c06dcc (const double x[], Integer lx, double xmin, double xmax, const double c[], Integer n, Nag_Series s, double res[], NagError *fail)
The function may be called by the names: c06dcc, nag_sum_chebyshev or nag_sum_cheby_series.

3 Description

c06dcc 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:
s=Nag_SeriesGeneral: 0.5c1+ j=2 n cj Tj-1 (x¯)
s=Nag_SeriesEven: 0.5c1+ j=2 n cj T 2j-2 (x¯)
s=Nag_SeriesOdd: j=1 n cj T 2j-1 (x¯)
where x¯ lies in the range -1.0x¯1.0. Here Tr(x) is the Chebyshev polynomial of order r in x¯, defined by cos(ry) where cosy=x¯.
It is assumed that the independent variable x¯ in the interval [-1.0,+1.0] was obtained from your original variable xX, a set of real numbers in the interval [xmin,xmax], 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 cj are normally generated by other functions, for example they may be those returned by the interpolation function e01aec (in vector a), by a least squares fitting function in Chapter E02, or as the solution of a boundary value problem by d02uec.

4 References

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

5 Arguments

1: x[lx] const double Input
On entry: xX, the set of arguments of the series.
Constraint: xminx[i-1]xmax, for i=1,2,,lx.
2: lx Integer Input
On entry: the number of evaluation points in X.
Constraint: lx1.
3: xmin double Input
4: xmax double Input
On entry: the lower and upper end points respectively of the interval [xmin,xmax]. The Chebyshev series representation is in terms of the normalized variable x¯, where
x¯ = 2x-(xmax+xmin) xmax-xmin .  
Constraint: xmin<xmax.
5: c[n] const double Input
On entry: c[j-1] must contain the coefficient cj of the Chebyshev series, for j=1,2,,n.
6: n Integer Input
On entry: n, the number of terms in the series.
Constraint: n1.
7: s Nag_Series Input
On entry: determines the series (see Section 3).
s=Nag_SeriesGeneral
The series is general.
s=Nag_SeriesEven
The series is even.
s=Nag_SeriesOdd
The series is odd.
Constraint: s=Nag_SeriesGeneral, Nag_SeriesEven or Nag_SeriesOdd.
8: res[lx] double Output
On exit: the Chebyshev series evaluated at the set of points X.
9: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, lx=value.
Constraint: lx1.
On entry, n=value.
Constraint: n1.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL_2
On entry, xmax=value and xmin=value.
Constraint: xmin<xmax.
NE_REAL_3
On entry, element x[value]=value, xmin=value and xmax=value.
Constraint: xminx[i]xmax, for all i.

7 Accuracy

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

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
c06dcc is not threaded in any implementation.

9 Further Comments

The time taken increases with n.

10 Example

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

10.1 Program Text

Program Text (c06dcce.c)

10.2 Program Data

Program Data (c06dcce.d)

10.3 Program Results

Program Results (c06dcce.r)