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_ode_bvp_ps_lin_cheb_eval (d02uz)

Purpose

nag_ode_bvp_ps_lin_cheb_eval (d02uz) returns the value of the kkth Chebyshev polynomial evaluated at a point x[1,1]x[-1,1]. nag_ode_bvp_ps_lin_cheb_eval (d02uz) is primarily a utility function for use by the Chebyshev boundary value problem solvers.

Syntax

[t, ifail] = d02uz(k, x)
[t, ifail] = nag_ode_bvp_ps_lin_cheb_eval(k, x)

Description

nag_ode_bvp_ps_lin_cheb_eval (d02uz) returns the value, TT, of the kkth Chebyshev polynomial evaluated at a point x[1,1]x[-1,1]; that is, T = cos(k × arccos(x))T=cos(k×arccos(x)).

References

Trefethen L N (2000) Spectral Methods in MATLAB SIAM

Parameters

Compulsory Input Parameters

1:     k – int64int32nag_int scalar
The order of the Chebyshev polynomial.
Constraint: k0k0.
2:     x – double scalar
The point at which to evaluate the polynomial.
Constraint: 1.0x1.0-1.0x1.0.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     t – double scalar
The value, TT, of the Chebyshev polynomial order kk evaluated at 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: k0k0.
  ifail = 2ifail=2
Constraint: 1.0x1.0-1.0x1.0.

Accuracy

The accuracy should be close to machine precision.

Further Comments

None.

Example

function nag_ode_bvp_ps_lin_cheb_eval_example
n = int64(16);
m = 9;
a = -0.24*pi;
b =  pi/2;


% Set up Chebyshev grid
[x, ifail] = nag_ode_bvp_ps_lin_cgl_grid(n, a, b);

% Evaluate function on grid.and get interpolating Chebyshev coefficients
f = x + exp(-x);
[c, ifail] = nag_ode_bvp_ps_lin_coeffs(n, f);

% Evaluate Chebyshev series manually by evaluating each Chebyshev
% polynomial in turn at new equispaced (m+1) grid points.
% Chebyshev series on [-1,1] map of [a,b].
xmap  = -1;
dmap  = 2/(m-1);
xeven = a;
deven = (b-a)/(m-1);

fprintf('\n    x_even     x_map      Sum\n');
for i=1:m
  fseries = 0;
  for k=0:double(n)
    [t, ifail] = nag_ode_bvp_ps_lin_cheb_eval(int64(k), xmap);
    fseries = fseries + c(k+1)*t;
  end
  fprintf('%10.4f %10.4f %10.4f\n', xmap, xeven, fseries);
  xmap = min(1, xmap+dmap);
  xeven = xeven + deven;
end
 

    x_even     x_map      Sum
   -1.0000    -0.7540     1.3715
   -0.7500    -0.4634     1.1261
   -0.5000    -0.1728     1.0158
   -0.2500     0.1178     1.0067
    0.0000     0.4084     1.0731
    0.2500     0.6990     1.1961
    0.5000     0.9896     1.3613
    0.7500     1.2802     1.5582
    1.0000     1.5708     1.7787

function d02uz_example
n = int64(16);
m = 9;
a = -0.24*pi;
b =  pi/2;


% Set up Chebyshev grid
[x, ifail] = d02uc(n, a, b);

% Evaluate function on grid.and get interpolating Chebyshev coefficients
f = x + exp(-x);
[c, ifail] = d02ua(n, f);

% Evaluate Chebyshev series manually by evaluating each Chebyshev
% polynomial in turn at new equispaced (m+1) grid points.
% Chebyshev series on [-1,1] map of [a,b].
xmap  = -1;
dmap  = 2/(m-1);
xeven = a;
deven = (b-a)/(m-1);

fprintf('\n    x_even     x_map      Sum\n');
for i=1:m
  fseries = 0;
  for k=0:double(n)
    [t, ifail] = d02uz(int64(k), xmap);
    fseries = fseries + c(k+1)*t;
  end
  fprintf('%10.4f %10.4f %10.4f\n', xmap, xeven, fseries);
  xmap = min(1, xmap+dmap);
  xeven = xeven + deven;
end
 

    x_even     x_map      Sum
   -1.0000    -0.7540     1.3715
   -0.7500    -0.4634     1.1261
   -0.5000    -0.1728     1.0158
   -0.2500     0.1178     1.0067
    0.0000     0.4084     1.0731
    0.2500     0.6990     1.1961
    0.5000     0.9896     1.3613
    0.7500     1.2802     1.5582
    1.0000     1.5708     1.7787


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