Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sum_withdraw_chebyshev (c06db)

## Purpose

nag_sum_withdraw_chebyshev (c06db) returns the value of the sum of a Chebyshev series through the function name.
Note: this function is scheduled to be withdrawn, please see c06db in Advice on Replacement Calls for Withdrawn/Superseded Routines..

## Syntax

[result] = c06db(x, c, s, 'n', n)
[result] = nag_sum_withdraw_chebyshev(x, c, s, 'n', n)

## Description

nag_sum_withdraw_chebyshev (c06db) evaluates the sum of a Chebyshev series of one of three forms according to the value of the parameter s:
s = 1 :
 n 0.5c1 + ∑ cjTj − 1(x), j = 2
s = 2 :
 n 0.5c1 + ∑ cjT2j − 2(x), j = 2
s = 3 :
 n ∑ cjT2j − 1(x) j = 1
$s=1: 0.5 c1 + ∑ j=2 n cj T j-1 (x) , s=2: 0.5 c1 + ∑ j=2 n cj T 2j-2 (x) , s=3: ∑ j=1 n cj T 2j-1 (x)$
where x$x$ lies in the range 1.0 x 1.0 $-1.0\le x\le 1.0$. Here Tr (x) ${T}_{r}\left(x\right)$ is the Chebyshev polynomial of order r$r$ in x$x$, defined by cos(ry) $\mathrm{cos}\left(ry\right)$ where cosy = x $\mathrm{cos}y=x$.
The method used is based upon a three-term recurrence relation; for details see Clenshaw (1962).

## References

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

## Parameters

### Compulsory Input Parameters

1:     x – double scalar
The argument x$x$ of the series.
Constraint: 1.0 x 1.0$-1.0\le {\mathbf{x}}\le 1.0$.
2:     c(n) – double array
c(j)${\mathbf{c}}\left(\mathit{j}\right)$ must contain the coefficient cj${c}_{\mathit{j}}$ of the Chebyshev series, for j = 1,2,,n$\mathit{j}=1,2,\dots ,n$.
3:     s – int64int32nag_int scalar
Must have the value 1$1$, 2$2$ or 3$3$ according to whether the series is general, even or odd respectively (see Section [Description]). For all other values of s, the function behaves as though s = 2${\mathbf{s}}=2$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array c.
n$n$, the number of terms in the series.

None.

### Output Parameters

1:     result – double scalar
The result of the function.

## Error Indicators and Warnings

If an error is detected in an input parameter nag_sum_withdraw_chebyshev (c06db) will act as if a soft noisy exit has been requested (see Section [Soft Fail Option] in the (essin)).

## Accuracy

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

The time taken increases with n$n$.
nag_sum_withdraw_chebyshev (c06db) 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_withdraw_chebyshev_example
x = 0.5;
c = [1;
1;
0.5;
0.25];
s = int64(1);
[result] = nag_sum_withdraw_chebyshev(x, c, s)
```
```

result =

0.5000

```
```function c06db_example
x = 0.5;
c = [1;
1;
0.5;
0.25];
s = int64(1);
[result] = c06db(x, c, s)
```
```

result =

0.5000

```