NAG Library Routine Document

c06dcf  (chebyshev)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

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)

3
Description

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.

4
References

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

5
Arguments

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).
s=1
The series is general.
s=2
The series is even.
s=3
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).

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:
ifail=1
On entry, lx=value.
Constraint: lx1.
ifail=2
On entry, n=value.
Constraint: n1.
ifail=3
On entry, s=value.
Constraint: s=1, 2 or 3.
ifail=4
On entry, xmax=value and xmin=value.
Constraint: xmin<xmax.
ifail=5
On entry, element xvalue=value, xmin=value and xmax=value.
Constraint: xminxixmax, for all i.
ifail=-99
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.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

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.

8
Parallelism and Performance

c06dcf is not threaded in any implementation.

9
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.

10
Example

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

10.1
Program Text

Program Text (c06dcfe.f90)

10.2
Program Data

Program Data (c06dcfe.d)

10.3
Program Results

Program Results (c06dcfe.r)

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