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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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 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 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:     xlx – double array
xX, the set of arguments of the series.
Constraint: xminxixmax, for i=1,2,,lx.
2:     xmin – double scalar
3:     xmax – double scalar
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.
4:     cn – double array
cj must contain the coefficient cj of the Chebyshev series, for j=1,2,,n.
5:     s int64int32nag_int scalar
Determines the series (see Description).
s=1
The series is general.
s=2
The series is even.
s=3
The series is odd.
Constraint: s=1, 2 or 3.

Optional Input Parameters

1:     lx int64int32nag_int scalar
Default: the dimension of the array x.
The number of evaluation points in X.
Constraint: lx1.
2:     n int64int32nag_int scalar
Default: the dimension of the array c.
n, the number of terms in the series.
Constraint: n1.

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: lx1.
   ifail=2
Constraint: n1.
   ifail=3
Constraint: s=1, 2 or 3.
   ifail=4
Constraint: xmin<xmax.
   ifail=5
Constraint: xminxixmax, for all i.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

There may be a loss of significant figures due to cancellation between terms. However, provided that n 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 n.
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

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


fprintf('c06dc example results\n\n');

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);


c06dc example results


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–2015