PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_ode_bvp_ps_lin_solve (d02ue)
Purpose
nag_ode_bvp_ps_lin_solve (d02ue) finds the solution of a linear constant coefficient boundary value problem by using the Chebyshev integration formulation on a Chebyshev Gauss–Lobatto grid.
Syntax
[
bmat,
f,
uc,
resid,
ifail] = d02ue(
n,
a,
b,
c,
bmat,
y,
bvec,
f, 'm',
m)
[
bmat,
f,
uc,
resid,
ifail] = nag_ode_bvp_ps_lin_solve(
n,
a,
b,
c,
bmat,
y,
bvec,
f, 'm',
m)
Description
nag_ode_bvp_ps_lin_solve (d02ue) solves the constant linear coefficient ordinary differential problem
subject to a set of
linear constraints at points
, for
:
where
,
is an
matrix of constant coefficients and
are constants. The points
are usually either
or
.
The function
is supplied as an array of Chebyshev coefficients
,
for the function discretized on
Chebyshev Gauss–Lobatto points (as returned by
nag_ode_bvp_ps_lin_cgl_grid (d02uc)); the coefficients are normally obtained by a previous call to
nag_ode_bvp_ps_lin_coeffs (d02ua). The solution and its derivatives (up to order
) are returned, in the form of their Chebyshev series representation, as arrays of Chebyshev coefficients; subsequent calls to
nag_ode_bvp_ps_lin_cgl_vals (d02ub) will return the corresponding function and derivative values at the Chebyshev Gauss–Lobatto discretization points on
. Function and derivative values can be obtained on any uniform grid over the same range
by calling the interpolation function
nag_ode_bvp_ps_lin_grid_vals (d02uw).
References
Clenshaw C W (1957) The numerical solution of linear differential equations in Chebyshev series Proc. Camb. Phil. Soc. 53 134–149
Coutsias E A, Hagstrom T and Torres D (1996) An efficient spectral method for ordinary differential equations with rational function coefficients Mathematics of Computation 65(214) 611–635
Greengard L (1991) Spectral integration and two-point boundary value problems SIAM J. Numer. Anal. 28(4) 1071–80
Lundbladh A, Hennigson D S and Johannson A V (1992) An efficient spectral integration method for the solution of the Navier–Stokes equations Technical report FFA–TN 1992–28 Aeronautical Research Institute of Sweden
Muite B K (2010) A numerical comparison of Chebyshev methods for solving fourth-order semilinear initial boundary value problems Journal of Computational and Applied Mathematics 234(2) 317–342
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, where the number of grid points is .
Constraint:
and
n is even.
- 2:
– double scalar
-
, the lower bound of domain .
Constraint:
.
- 3:
– double scalar
-
, the upper bound of domain .
Constraint:
.
- 4:
– double array
-
The Chebyshev coefficients
,
, for the right hand side of the boundary value problem. Usually these are obtained by a previous call of
nag_ode_bvp_ps_lin_coeffs (d02ua).
- 5:
– double array
-
must contain the coefficients
, for
and
, in the problem formulation of
Description.
- 6:
– double array
-
The points,
, for , where the boundary conditions are discretized.
- 7:
– double array
-
The values,
, for
, in the formulation of the boundary conditions given in
Description.
- 8:
– double array
-
The coefficients,
, for
, in the formulation of the linear boundary value problem given in
Description. The highest order term,
, needs to be nonzero to have a well posed problem.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
bmat and the dimension of the arrays
y,
bvec. (An error is raised if these dimensions are not equal.)
The order, , of the boundary value problem to be solved.
Constraint:
.
Output Parameters
- 1:
– double array
-
The coefficients have been scaled to form an equivalent problem defined on the domain .
- 2:
– double array
-
The coefficients have been scaled to form an equivalent problem defined on the domain .
- 3:
– double array
-
The Chebyshev coefficients in the Chebyshev series representations of the solution and derivatives of the solution to the boundary value problem. The elements contain the coefficients representing the solution
, for .
contains the coefficients representing the th derivative of , for .
- 4:
– double scalar
-
The maximum residual resulting from substituting the solution vectors returned in
uc into both linear equations of
Description representing the linear boundary value problem and associated boundary conditions. That is
- 5:
– 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:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
Constraint: .
-
-
Constraint: .
-
-
On entry, .
-
-
Constraint: .
-
-
Internal error while unpacking matrix during iterative refinement.
Please contact
NAG.
-
-
Singular matrix encountered during iterative refinement.
Please check that your system is well posed.
- W
-
During iterative refinement, the maximum number of iterations was reached.
- W
-
During iterative refinement, convergence was achieved, but the residual is more than .
-
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 accuracy should be close to
machine precision for well conditioned boundary value problems.
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 ). Collocation methods will be faster for small problems, but the method of nag_ode_bvp_ps_lin_solve (d02ue) should be faster for larger discretizations.
Example
This example solves the third-order problem on subject to the boundary conditions , , and using the Chebyshev integration formulation on a Chebyshev Gauss–Lobatto grid of order .
Open in the MATLAB editor:
d02ue_example
function d02ue_example
fprintf('d02ue example results\n\n');
n = int64(16);
a = -pi/2;
b = pi/2;
y = [a, b];
bmat = zeros(2, 3);
bmat(1, 1:2) = [1, 1];
bmat(2, 1:2) = [1, 1];
bvec = [cos(a) - sin(a), cos(b) - sin(b)];
f = [1, 2, 3];
[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(n+1, 3);
for q=0:2
[u(:, q+1), ifail] = d02ub(n, a, b, int64(q), uc(:, q+1));
end
fprintf('\nNumerical solution U and its first two derivatives\n');
fprintf(' x U Ux Uxx\n');
fprintf('%10.4f %10.4f %10.4f %10.4f\n', [x u]');
d02ue example results
Numerical solution U and its first two derivatives
x U Ux Uxx
-1.5708 -0.0000 1.0000 0.0000
-1.5406 0.0302 0.9995 -0.0302
-1.4512 0.1193 0.9929 -0.1193
-1.3061 0.2616 0.9652 -0.2616
-1.1107 0.4440 0.8960 -0.4440
-0.8727 0.6428 0.7661 -0.6428
-0.6011 0.8247 0.5656 -0.8247
-0.3064 0.9534 0.3017 -0.9534
-0.0000 1.0000 0.0000 -1.0000
0.3064 0.9534 -0.3017 -0.9534
0.6011 0.8247 -0.5656 -0.8247
0.8727 0.6428 -0.7661 -0.6428
1.1107 0.4440 -0.8960 -0.4440
1.3061 0.2616 -0.9652 -0.2616
1.4512 0.1193 -0.9929 -0.1193
1.5406 0.0302 -0.9995 -0.0302
1.5708 -0.0000 -1.0000 -0.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015