nag_sum_cheby_series (c06dcc) (PDF version)
c06 Chapter Contents
c06 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_sum_cheby_series (c06dcc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_sum_cheby_series (c06dcc) evaluates a polynomial from its Chebyshev series representation at a set of points.

2  Specification

#include <nag.h>
#include <nagc06.h>
void  nag_sum_cheby_series (const double x[], Integer lx, double xmin, double xmax, const double c[], Integer n, Nag_Series s, double res[], NagError *fail)

3  Description

nag_sum_cheby_series (c06dcc) 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=Nag_SeriesGeneral: 0.5c1+ j=2 n cj Tj-1 x-  
s=Nag_SeriesEven: 0.5c1+ j=2 n cj T 2j-2 x-  
s=Nag_SeriesOdd: 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_1d_cheb_interp (e01aec) (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_ps_lin_solve (d02uec).

4  References

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

5  Arguments

1:     x[lx]const doubleInput
On entry: xX, the set of arguments of the series.
Constraint: xminx[i-1]xmax, for i=1,2,,lx.
2:     lxIntegerInput
On entry: the number of evaluation points in X.
Constraint: lx1.
3:     xmindoubleInput
4:     xmaxdoubleInput
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]const doubleInput
On entry: c[j-1] must contain the coefficient cj of the Chebyshev series, for j=1,2,,n.
6:     nIntegerInput
On entry: n, the number of terms in the series.
Constraint: n1.
7:     sNag_SeriesInput
On entry: determines the series (see Section 3).
s=Nag_SeriesGeneral
The series is general.
s=Nag_SeriesEven
The series is even.
s=Nag_SeriesOdd
The series is odd.
Constraint: s=Nag_SeriesGeneral, Nag_SeriesEven or Nag_SeriesOdd.
8:     res[lx]doubleOutput
On exit: the Chebyshev series evaluated at the set of points X.
9:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, lx=value.
Constraint: lx1.
On entry, n=value.
Constraint: n1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_2
On entry, xmax=value and xmin=value.
Constraint: xmin<xmax.
NE_REAL_3
On entry, element x[value]=value, xmin=value and xmax=value.
Constraint: xminx[i]xmax, for all i.

7  Accuracy

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

8  Further Comments

The time taken increases with n.

9  Example

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

9.1  Program Text

Program Text (c06dcce.c)

9.2  Program Data

Program Data (c06dcce.d)

9.3  Program Results

Program Results (c06dcce.r)


nag_sum_cheby_series (c06dcc) (PDF version)
c06 Chapter Contents
c06 Chapter Introduction
NAG C Library Manual

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