NAG Library Routine Document

c06dcf (chebyshev)


    1  Purpose
    7  Accuracy


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


Fortran Interface
Subroutine c06dcf ( x, lx, xmin, xmax, c, n, s, res, ifail)
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)
C Header Interface
#include nagmk26.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)


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:
s=1: 0.5c1+ j=2 n cj Tj-1 x-  
s=2: 0.5c1+ j=2 n cj T 2j-2 x-  
s=3: j=1 n cj T 2j-1 x-  
where x- lies in the range -1.0x-1.0. Here Trx is the Chebyshev polynomial of order r in x-, defined by cosry 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 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


1:     xlx – Real (Kind=nag_wp) arrayInput
On entry: xX, the set of arguments of the series.
Constraint: xminxixmax, for i=1,2,,lx.
2:     lx – IntegerInput
On entry: the number of evaluation points in X.
Constraint: lx1.
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 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:     cn – Real (Kind=nag_wp) arrayInput
On entry: cj must contain the coefficient cj of the Chebyshev series, for j=1,2,,n.
6:     n – IntegerInput
On entry: n, the number of terms in the series.
Constraint: n1.
7:     s – IntegerInput
On entry: determines the series (see Section 3).
The series is general.
The series is even.
The series is odd.
Constraint: s=1, 2 or 3.
8:     reslx – 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​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ 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 argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry 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:
On entry, lx=value.
Constraint: lx1.
On entry, n=value.
Constraint: n1.
On entry, s=value.
Constraint: s=1, 2 or 3.
On entry, xmax=value and xmin=value.
Constraint: xmin<xmax.
On entry, element xvalue=value, xmin=value and xmax=value.
Constraint: xminxixmax, for all i.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


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.

Parallelism and Performance

c06dcf is not threaded in any implementation.

Further Comments

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.


This example evaluates
0.5+ T1x+ 0.5T2x+ 0.25T3x  
at the points X=0.5,1.0,-0.2.

Program Text

Program Text (c06dcfe.f90)

Program Data

Program Data (c06dcfe.d)

Program Results

Program Results (c06dcfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017