NAG FL Interface
c06dcf (chebyshev)

Settings help

FL Name Style:


FL Specification Language:


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 <nag.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)
The routine may be called by the names c06dcf or nagf_sum_chebyshev.

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 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 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: x(lx) Real (Kind=nag_wp) array Input
On entry: xX, the set of arguments of the series.
Constraint: xminx(i)xmax, for i=1,2,,lx.
2: lx Integer Input
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: c(n) Real (Kind=nag_wp) array Input
On entry: c(j) 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 Integer Input
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: res(lx) Real (Kind=nag_wp) array Output
On exit: the Chebyshev series evaluated at the set of points X.
9: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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 x(value)=value, xmin=value and xmax=value.
Constraint: xminx(i)xmax, for all i.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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+ T1(x)+ 0.5T2(x)+ 0.25T3(x)  
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)