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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_ode_bvp_ps_lin_cheb_eval (d02uz) returns the value of the kth Chebyshev polynomial evaluated at a point 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, T, of the kth Chebyshev polynomial evaluated at a point x-1,1; that is, T=cosk×arccosx.

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: k0.
2:     x – double scalar
The point at which to evaluate the polynomial.
Constraint: -1.0x1.0.

Optional Input Parameters

None.

Output Parameters

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

The accuracy should be close to machine precision.

Further Comments

None.

Example

A set of Chebyshev coefficients is obtained for the function x+exp-x defined on -0.24×π,0.5×π using nag_ode_bvp_ps_lin_cgl_grid (d02uc). At each of a set of new grid points in the domain of the function nag_ode_bvp_ps_lin_cheb_eval (d02uz) is used to evaluate each Chebshev polynomial in the series representation. The values obtained are multiplied to the Chebyshev coefficients and summed to obtain approximations to the given function at the new grid points.
function d02uz_example


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

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].
dmap  = 2/(m-1);
xmap  = [-1:dmap:1];
deven = (b-a)/(m-1);
xeven = [a:deven:b];

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


d02uz example results

    x_even     x_map      Sum(f)
   -1.0000    -0.7500    -0.5000
   -0.2500     0.0000     0.2500
    0.5000     0.7500     1.0000
   -0.7540    -0.4634    -0.1728
    0.1178     0.4084     0.6990
    0.9896     1.2802     1.5708
    1.3715     1.1261     1.0158
    1.0067     1.0731     1.1961
    1.3613     1.5582     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–2015