PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_ode_bvp_ps_lin_coeffs (d02ua)
Purpose
nag_ode_bvp_ps_lin_coeffs (d02ua) obtains the Chebyshev coefficients of a function discretized on Chebyshev Gauss–Lobatto points. The set of discretization points on which the function is evaluated is usually obtained by a previous call to
nag_ode_bvp_ps_lin_cgl_grid (d02uc).
Syntax
[
c,
ifail] = nag_ode_bvp_ps_lin_coeffs(
n,
f)
Description
nag_ode_bvp_ps_lin_coeffs (d02ua) computes the coefficients
, for
, of the interpolating Chebyshev series
which interpolates the function
evaluated at the Chebyshev Gauss–Lobatto points
Here
denotes the Chebyshev polynomial of the first kind of degree
with argument
defined on
. In terms of your original variable,
say, the input values at which the function values are to be provided are
where
and
are respectively the upper and lower ends of the range of
over which the function is required.
References
Canuto C (1988) Spectral Methods in Fluid Dynamics 502 Springer
Canuto C, Hussaini M Y, Quarteroni A and Zang T A (2006) Spectral Methods: Fundamentals in Single Domains Springer
Trefethen L N (2000) Spectral Methods in MATLAB SIAM
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, where the number of grid points is . This is also the largest order of Chebyshev polynomial in the Chebyshev series to be computed.
Constraint:
and
n is even.
- 2:
– double array
-
The function values
, for .
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The Chebyshev coefficients,
, for .
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The Chebyshev coefficients computed should be accurate to within a small multiple of
machine precision.
Further Comments
The number of operations is of the order and the memory requirements are ; thus the computation remains efficient and practical for very fine discretizations (very large values of ).
Example
See
Example in
nag_ode_bvp_ps_lin_solve (d02ue).
Open in the MATLAB editor:
d02ua_example
function d02ua_example
fprintf('d02ua example results\n\n');
a = 0;
b = 4;
n = int64(128);
[x, ifail] = d02uc(n, a, b);
z = 10*x.*cos(x).^2;
f0 = sin(z) - 10*cos(x).^2.*cos(10*x.*cos(x).^2).*(2*x.*tan(x)-1);
[f0_c, ifail] = d02ua(n, f0);
f = [1, 1];
y = [a];
B = [1, 0];
beta = 0;
[B, f, uc, resid, ifail] = d02ue(...
n, a, b, f0_c, B, y, beta, f);
[u, ifail] = d02ub(...
n, a, b, int64(0), uc(:, 1));
[ux, ifail] = d02ub(...
n, a, b, int64(1), uc(:, 2));
maxerr = max(abs(u - sin(z)));
fprintf('With n = %4d, maximum error in solution = %13.2e\n',n,maxerr);
fig1 = figure;
plot(x,u,x,ux);
title('Solution of u + u_x = f_0 on [0,4]');
xlabel('x');
ylabel('u(x) and u_x(x)');
legend('u','u_x','Location','Northwest');
d02ua example results
With n = 128, maximum error in solution = 5.33e-09
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015