hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_sum_chebyshev (c06dc)

Purpose

nag_sum_chebyshev (c06dc) evaluates a polynomial from its Chebyshev series representation at a set of points.

Syntax

[res, ifail] = c06dc(x, xmin, xmax, c, s, 'lx', lx, 'n', n)
[res, ifail] = nag_sum_chebyshev(x, xmin, xmax, c, s, 'lx', lx, 'n', n)

Description

nag_sum_chebyshev (c06dc) evaluates, at each point in a given set XX, the sum of a Chebyshev series of one of three forms according to the value of the parameter s:
s = 1s=1: 0.5c1 + j = 2n cj Tj1 (x) 0.5c1+ j=2 n cj Tj-1 (x-)  
s = 2s=2: 0.5c1 + j = 2n cj T2j2 (x) 0.5c1+ j=2 n cj T 2j-2 (x-)  
s = 3s=3: j = 1n cj T2j1 (x) j=1 n cj T 2j-1 (x-)  
where xx- lies in the range 1.0x1.0-1.0x-1.0. Here Tr(x)Tr(x) is the Chebyshev polynomial of order rr in xx-, defined by cos(ry)cos(ry) where cosy = xcosy=x-
It is assumed that the independent variable xx- in the interval [1.0, + 1.0][-1.0,+1.0] was obtained from your original variable xXxX, a set of real numbers in the interval [xmin,xmax][xmin,xmax], by the linear transformation
x = (2x(xmax + xmin))/(xmaxxmin) .
x- = 2x-(xmax+xmin) xmax-xmin .
The method used is based upon a three-term recurrence relation; for details see Clenshaw (1962).
The coefficients cjcj are normally generated by other functions, for example they may be those returned by the interpolation function nag_interp_1d_cheb (e01ae) (in vector a), by a least squares fitting function in Chapter E02, or as the solution of a boundary value problem by nag_ode_bvp_coll_nth (d02ja), nag_ode_bvp_coll_sys (d02jb) or nag_ode_bvp_ps_lin_solve (d02ue).

References

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

Parameters

Compulsory Input Parameters

1:     x(lx) – double array
lx, the dimension of the array, must satisfy the constraint lx1lx1.
xXxX, the set of arguments of the series.
Constraint: xminx(i)xmaxxminxixmax, for i = 1,2,,lxi=1,2,,lx.
2:     xmin – double scalar
3:     xmax – double scalar
The lower and upper end points respectively of the interval [xmin,xmax][xmin,xmax]. The Chebyshev series representation is in terms of the normalized variable xx-, where
x = (2x(xmax + xmin))/(xmaxxmin) .
x- = 2x-(xmax+xmin) xmax-xmin .
Constraint: xmin < xmaxxmin<xmax.
4:     c(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
c(j)cj must contain the coefficient cjcj of the Chebyshev series, for j = 1,2,,nj=1,2,,n.
5:     s – int64int32nag_int scalar
Determines the series (see Section [Description]).
s = 1s=1
The series is general.
s = 2s=2
The series is even.
s = 3s=3
The series is odd.
Constraint: s = 1s=1, 22 or 33.

Optional Input Parameters

1:     lx – int64int32nag_int scalar
Default: The dimension of the array x.
The number of evaluation points in XX.
Constraint: lx1lx1.
2:     n – int64int32nag_int scalar
Default: The dimension of the array c.
nn, the number of terms in the series.
Constraint: n1n1.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     res(lx) – double array
The Chebyshev series evaluated at the set of points XX.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

  ifail = 1ifail=1
Constraint: lx1lx1.
  ifail = 2ifail=2
Constraint: n1n1.
  ifail = 3ifail=3
Constraint: s = 1s=1, 22 or 33.
  ifail = 4ifail=4
Constraint: xmin < xmaxxmin<xmax.
  ifail = 5ifail=5
Constraint: xminx(i)xmaxxminxixmax, for all ii.

Accuracy

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

Further Comments

The time taken increases with nn.
nag_sum_chebyshev (c06dc) has been prepared in the present form to complement a number of integral equation solving functions which use Chebyshev series methods, e.g., nag_inteq_fredholm2_split (d05aa) and nag_inteq_fredholm2_smooth (d05ab).

Example

function nag_sum_chebyshev_example
x = [0.5, 1.0, -0.2];
xmin = -1;
xmax =  1;
s = int64(1);
c = [1.0, 1.0, 0.5, 0.25];

[res, ifail] = nag_sum_chebyshev(x, xmin, xmax, c, s);
fprintf('\nSums: \n');
disp(res);
 

Sums: 
    0.5000
    2.2500
   -0.0180


function c06dc_example
x = [0.5, 1.0, -0.2];
xmin = -1;
xmax =  1;
s = int64(1);
c = [1.0, 1.0, 0.5, 0.25];

[res, ifail] = c06dc(x, xmin, xmax, c, s);
fprintf('\nSums: \n');
disp(res);
 

Sums: 
    0.5000
    2.2500
   -0.0180



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013