PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_ode_bvp_ps_lin_cgl_vals (d02ub)
Purpose
nag_ode_bvp_ps_lin_cgl_vals (d02ub) evaluates a function, or one of its lower order derivatives, from its Chebyshev series representation at Chebyshev Gauss–Lobatto points on
. The coefficients of the Chebyshev series representation required are usually derived from those returned by
nag_ode_bvp_ps_lin_coeffs (d02ua) or
nag_ode_bvp_ps_lin_solve (d02ue).
Syntax
[
f,
ifail] = nag_ode_bvp_ps_lin_cgl_vals(
n,
a,
b,
q,
c)
Description
nag_ode_bvp_ps_lin_cgl_vals (d02ub) evaluates the Chebyshev series
or its derivative (up to fourth order) at the Chebyshev Gauss–Lobatto points on
. 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.
The calculation is implemented by a forward one-dimensional discrete Fast Fourier Transform (DFT).
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 scalar
-
, the lower bound of domain .
Constraint:
.
- 3:
– double scalar
-
, the upper bound of domain .
Constraint:
.
- 4:
– int64int32nag_int scalar
-
The order, , of the derivative to evaluate.
Constraint:
.
- 5:
– double array
-
The Chebyshev coefficients,
, for .
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The derivatives
, for , of the Chebyshev series, .
- 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: .
-
-
Constraint: .
-
-
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
Evaluations of DFT to obtain function or derivative values should be an order
multiple of
machine precision assuming full accuracy to
machine precision in the given Chebyshev series representation.
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:
d02ub_example
function d02ub_example
fprintf('d02ub example results\n\n');
n = int64(16);
a = -pi/2;
b = pi/2;
y = [a, a, b];
bmat = zeros(3, 4);
bmat(1, 1) = 1;
bmat(2, 1:3) = [1, 2, 3];
bmat(3, 1:3) = [1, 2, 3];
bvec = [0, 2, -2];
f = [1, 2, 3, 4];
[x, ifail] = d02uc(n, a, b);
f0 = 2*sin(x) - 2*cos(x);
[c, ifail] = d02ua(n, f0);
[bmat, f, uc, resid, ifail] = d02ue(n, a, b, c, bmat, y, bvec, f);
u = zeros(17, 4);
for q=0:3
[u(:, q+1), ifail] = d02ub(n, a, b, int64(q), uc(:, q+1));
end
fprintf('\nNumerical solution U and its first three derivatives\n');
fprintf(' x U Ux Uxx Uxxx\n');
for i=1:17
fprintf('%10.4f %10.4f %10.4f %10.4f %10.4f\n', x(i), u(i, :));
end
d02ub example results
Numerical solution U and its first three derivatives
x U Ux Uxx Uxxx
-1.5708 -0.0000 1.0000 0.0000 -1.0000
-1.5406 0.0302 0.9995 -0.0302 -0.9995
-1.4512 0.1193 0.9929 -0.1193 -0.9929
-1.3061 0.2616 0.9652 -0.2616 -0.9652
-1.1107 0.4440 0.8960 -0.4440 -0.8960
-0.8727 0.6428 0.7661 -0.6428 -0.7661
-0.6011 0.8247 0.5656 -0.8247 -0.5656
-0.3064 0.9534 0.3017 -0.9534 -0.3017
-0.0000 1.0000 0.0000 -1.0000 -0.0000
0.3064 0.9534 -0.3017 -0.9534 0.3017
0.6011 0.8247 -0.5656 -0.8247 0.5656
0.8727 0.6428 -0.7661 -0.6428 0.7661
1.1107 0.4440 -0.8960 -0.4440 0.8960
1.3061 0.2616 -0.9652 -0.2616 0.9652
1.4512 0.1193 -0.9929 -0.1193 0.9929
1.5406 0.0302 -0.9995 -0.0302 0.9995
1.5708 -0.0000 -1.0000 0.0000 1.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015