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_coll_nth_comp (d02tg)

Purpose

nag_ode_bvp_coll_nth_comp (d02tg) solves a system of linear ordinary differential equations by least squares fitting of a series of Chebyshev polynomials using collocation.

Syntax

[c, ifail] = d02tg(m, l, x0, x1, k1, kp, coeff, bdyc, 'n', n)
[c, ifail] = nag_ode_bvp_coll_nth_comp(m, l, x0, x1, k1, kp, coeff, bdyc, 'n', n)

Description

nag_ode_bvp_coll_nth_comp (d02tg) calculates an approximate solution of a linear or linearized system of ordinary differential equations as a Chebyshev series. Suppose there are nn differential equations for nn variables y1,y2,,yny1,y2,,yn, over the range (x0,x1)(x0,x1). Let the iith equation be
mi + 1n
fkji(x)yk(j1)(x) = ri(x)
j = 1k = 1
j=1 mi+1 k=1 n fkji(x) y k(j-1) (x)= ri(x)
where yk(j)(x) = (djyk(x))/(dxj) yk (j) (x)=djyk(x) dxj . coeff evaluates the coefficients fkji(x)fkji(x) and the right-hand side ri(x)ri(x) for each ii, 1in1in, at any point xx. The boundary conditions may be applied either at the end points or at intermediate points; they are written in the same form as the differential equations, and specified by bdyc. For example the jjth boundary condition out of those associated with the iith differential equation takes the form
li + 1n
fkjij(xij)yk(j1)(xij) = rij(xij),
j = 1k = 1
j=1 li+1 k=1 n f kj ij (xij) yk(j-1) (xij)=rij (xij) ,
where xijxij lies between x0x0 and x1x1. It is assumed in this function that certain of the boundary conditions are associated with each differential equation. This is for your convenience; the grouping does not affect the results.
The degree of the polynomial solution must be the same for all variables. You specify the degree required, k11k1-1, and the number of collocation points, kpkp, in the range. The function sets up a system of linear equations for the Chebyshev coefficients, with nn equations for each collocation point and one for each boundary condition. The collocation points are chosen at the extrema of a shifted Chebyshev polynomial of degree kp1kp-1. The boundary conditions are satisfied exactly, and the remaining equations are solved by a least squares method. The result produced is a set of Chebyshev coefficients for the nn functions y1,y2,,yny1,y2,,yn, with the range normalized to [1,1][-1,1].
nag_fit_1dcheb_eval2 (e02ak) can be used to evaluate the components of the solution at any point on the range [x0,x1][x0,x1] (see Section [Example] for an example). nag_fit_1dcheb_deriv (e02ah) and nag_fit_1dcheb_integ (e02aj) may be used to obtain Chebyshev series representations of derivatives and integrals (respectively) of the components of the solution.

References

Picken S M (1970) Algorithms for the solution of differential equations in Chebyshev-series by the selected points method Report Math. 94 National Physical Laboratory

Parameters

Compulsory Input Parameters

1:     m(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n1n1.
m(i)mi must be set to the highest order derivative occurring in the iith equation, for i = 1,2,,ni=1,2,,n.
Constraint: m(i)1mi1, for i = 1,2,,ni=1,2,,n.
2:     l(n) – int64int32nag_int array
n, the dimension of the array, must satisfy the constraint n1n1.
l(i)li must be set to the number of boundary conditions associated with the iith equation, for i = 1,2,,ni=1,2,,n.
Constraint: l(i)0li0, for i = 1,2,,ni=1,2,,n.
3:     x0 – double scalar
The left-hand boundary, x0x0.
4:     x1 – double scalar
The right-hand boundary, x1x1.
Constraint: x1 > x0x1>x0.
5:     k1 – int64int32nag_int scalar
The number of coefficients, k1k1, to be returned in the Chebyshev series representation of the solution (hence, the degree of the polynomial approximation is k11k1-1).
Constraint: k11 + max1in  m(i) k11+ max 1in mi.
6:     kp – int64int32nag_int scalar
The number of collocation points to be used, kpkp.
Constraint: n × kpn × k1 + i = 1n l(i) n×kpn×k1+ i=1 n li .
7:     coeff – function handle or string containing name of m-file
coeff defines the system of differential equations (see Section [Description]). It must evaluate the coefficient functions fkji(x)fkji(x) and the right-hand side function ri(x)ri(x) of the iith equation at a given point. Only nonzero entries of the array a and rhs need be specifically assigned, since all elements are set to zero by nag_ode_bvp_coll_nth_comp (d02tg) before calling coeff.
[a, rhs] = coeff(x, ii, a, ia, ia1, rhs)

Input Parameters

1:     x – double scalar
xx, the point at which the functions must be evaluated.
2:     ii – int64int32nag_int scalar
The equation for which the coefficients and right-hand side are to be evaluated.
3:     a(ia,ia1) – double array
All elements of a are set to zero.
4:     ia – int64int32nag_int scalar
5:     ia1 – int64int32nag_int scalar
The first dimension of the array a and the second dimension of the array a as declared in the (sub)program from which nag_ode_bvp_coll_nth_comp (d02tg) is called.
6:     rhs – double scalar
Is set to zero.

Output Parameters

1:     a(ia,ia1) – double array
a(k,j)akj must contain the value fkji(x)fkji(x), for 1kn1kn, 1jmi + 11jmi+1.
2:     rhs – double scalar
It must contain the value ri(x)ri(x).
8:     bdyc – function handle or string containing name of m-file
bdyc defines the boundary conditions (see Section [Description]). It must evaluate the coefficient functions fkjijfkj ij and right-hand side function rijrij in the jjth boundary condition associated with the iith equation, at the point xijxij at which the boundary condition is applied. Only nonzero entries of the array a and rhs need be specifically assigned, since all elements are set to zero by nag_ode_bvp_coll_nth_comp (d02tg) before calling bdyc.
[x, a, rhs] = bdyc(ii, j, a, ia, ia1, rhs)

Input Parameters

1:     ii – int64int32nag_int scalar
The differential equation with which the condition is associated.
2:     j – int64int32nag_int scalar
The boundary condition for which the coefficients and right-hand side are to be evaluated.
3:     a(ia,ia1) – double array
All elements of a are set to zero.
4:     ia – int64int32nag_int scalar
5:     ia1 – int64int32nag_int scalar
The first dimension of the array a and the second dimension of the array a as declared in the (sub)program from which nag_ode_bvp_coll_nth_comp (d02tg) is called.
6:     rhs – double scalar
Is set to zero.

Output Parameters

1:     x – double scalar
xijxij, the value at which the boundary condition is applied.
2:     a(ia,ia1) – double array
The value fkjij (xij) f kj ij (xij) , for 1kn1kn, 1jmi + 11jmi+1.
3:     rhs – double scalar
The value rij (xij) rij (xij) .

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays m, l. (An error is raised if these dimensions are not equal.)
nn, the number of differential equations in the system.
Constraint: n1n1.

Input Parameters Omitted from the MATLAB Interface

ldc w lw iw liw

Output Parameters

1:     c(ldc,n) – double array
ldck1ldck1.
The kkth column of c contains the computed Chebyshev coefficients of the kkth component of the solution, ykyk; that is, the computed solution is:
k1
yk = c(i,k)Ti1(x),  1kn,
i = 1
yk=i=1k1cikTi-1(x),  1kn,
where Ti(x)Ti(x) is the Chebyshev polynomial of the first kind and denotes that the first coefficient, c(1,k)c1k, is halved.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1,
orm(i) < 1mi<1 for some ii,
orl(i) < 0li<0 for some ii,
orx0x1x0x1,
ork1 < 1 + m(i)k1<1+mi for some ii,
or n × kp < n × k1 + i = 1nl(i) n×kp<n×k1+ i=1 n li ,
orldc < k1ldc<k1.
  ifail = 2ifail=2
On entry,lw is too small (see Section [Parameters]),
orliw < n × k1liw<n×k1.
  ifail = 3ifail=3
Either the boundary conditions are not linearly independent, or the rank of the matrix of equations for the coefficients is less than the number of unknowns. Increasing kp may overcome this latter problem.
  ifail = 4ifail=4
The least squares function nag_linsys_real_gen_lsqsol (f04am) has failed to correct the first approximate solution (see nag_linsys_real_gen_lsqsol (f04am)). Increasing kp may remove this difficulty.

Accuracy

Estimates of the accuracy of the solution may be obtained by using the checks described in Section [Further Comments]. The Chebyshev coefficients are calculated by a stable numerical method.

Further Comments

The time taken by nag_ode_bvp_coll_nth_comp (d02tg) depends on the complexity of the system of differential equations, the degree of the polynomial solution and the number of matching points.
If the number of matching points kpkp is equal to the number of coefficients k1k1 minus the average number of boundary conditions 1/n i = 1n li 1n i=1 n li , then the least squares solution reduces to simple solution of linear equations and true collocation results. The accuracy of the solution may be checked by repeating the calculation with different values of k1k1. If the Chebyshev coefficients decrease rapidly, the size of the last two or three gives an indication of the error. If they do not decrease rapidly, it may be desirable to use a different method. Note that the Chebyshev coefficients are calculated for the range normalized to [1,1][-1,1].
Generally the number of boundary conditions required is equal to the sum of the orders of the nn differential equations. However, in some cases fewer boundary conditions are needed, because the assumption of a polynomial solution is equivalent to one or more boundary conditions (since it excludes singular solutions).
A system of nonlinear differential equations must be linearized before using the function. The calculation is repeated iteratively. On each iteration the linearized equation is used. In the example in Section [Example], the yy variables are to be determined at the current iteration whilst the zz variables correspond to the solution determined at the previous iteration, (or the initial approximation on the first iteration). For a starting approximation, we may take, say, a linear function, and set up the appropriate Chebyshev coefficients before starting the iteration. For example, if y1 = ax + by1=ax+b in the range (x0,x1)(x0,x1), we set BB, the array of coefficients,
In some cases a better initial approximation may be needed and can be obtained by using nag_fit_1dcheb_arb (e02ad) or nag_fit_1dcheb_glp (e02af) to obtain a Chebyshev series for an approximate solution. The coefficients of the current iterate must be communicated to coeff and bdyc, e.g., via a global variable. (See Section [Example].) The convergence of the (Newton) iteration cannot be guaranteed in general, though it is usually satisfactory from a good starting approximation.

Example

This example solves the nonlinear system
2y1 + (y221) y1 + y2 = 0,
2y2y1 = 0,
2y1+(y22-1) y1+y2=0, 2y2-y1=0,
in the range (1,1)(-1,1), with y1 = 0y1=0, y2 = 3y2=3, y2 = 0y2=0 at x = 1x=-1.
Suppose an approximate solution is z1z1, z2z2 such that y1z1y1z1, y2z2y2z2: then the first equation gives, on linearizing,
2y1 + (z221) y1 + (2z1z2 + 1) y2 = 2z1z22.
2y1+(z22-1) y1+(2z1z2+1) y2=2z1z22.
The starting approximation is taken to be z1 = 0z1=0, z2 = 3z2=3. In the program below, the array BB is used to hold the coefficients of the previous iterate (or of the starting approximation). We iterate until the Chebyshev coefficients converge to five figures. nag_fit_1dcheb_eval2 (e02ak) is used to calculate the solution from its Chebyshev coefficients.
function nag_ode_bvp_coll_nth_comp_example
global b x0 x1 ndegree % For communication with coeff.

% Initialize variables and arrays.
x0 = -1;
x1 = 1;
ncolloc = 15;
neqn = 2;
ncoeff = 9;

nderiv = [1; 2];
nbc = [1; 2];

% Set initial values for Chebyshev series coefficients.
b = zeros(ncoeff, neqn);
b(1,2) = 6.0;

% The degree of the Chebyshev polynomial (as used in nag_fit_1dcheb_eval2) is one less
% than the number of coefficients (as used in nag_ode_bvp_coll_nth_comp).
ndegree = ncoeff-1;

fprintf('nag_ode_bvp_coll_nth_comp example program results\n');

% Initial iteration.
iter = 1;
[c, ifail] = nag_ode_bvp_coll_nth_comp(int64(nderiv), int64(nbc), x0, x1, int64(ncoeff), ...
    int64(ncolloc), @coeff, @bdyc, 'n', int64(neqn));
if ifail ~= 0
    % Unsuccessful call.  Print message and exit.
    error('Warning: nag_ode_bvp_coll_nth_comp returned with ifail = %1d ',ifail);
end

% Output new estimate for coefficients.
fprintf(['\n Iteration ', num2str(iter), ...
    '. Chebyshev coefficients are:\n']);
for j = 1:neqn
    for i = 1:ncoeff
        fprintf('%8.4f',c(i,j));
    end
    fprintf('\n');
end

% Calculate change in coefficients.
emax = 0.0;
for j = 1:neqn; i = 1:ncoeff;
    emax = max(max(emax,abs(c(i,j) - b(i,j))));
    b(i,j) = c(i,j);
end

% Iterate until the change is small enough.
while emax >= 1.0e-05
    iter = iter + 1;

    [c, ifail] = nag_ode_bvp_coll_nth_comp(int64(nderiv), int64(nbc), x0, x1, ...
        int64(ncoeff), int64(ncolloc), @coeff, @bdyc, ...
        'n', int64(neqn));
    if ifail ~= 0
        % Unsuccessful call.  Print message and exit.
        error('Warning: nag_ode_bvp_coll_nth_comp returned with ifail = %1d ',ifail);
    end

    % Output coefficients.
    fprintf(['\n Iteration ', num2str(iter), ...
        '. Chebyshev coefficients are:\n']);
    for j = 1:neqn
        for i = 1:ncoeff
            fprintf('%8.4f',c(i,j));
        end
        fprintf('\n');
    end

    emax = 0.0;
    for j = 1:neqn; i = 1:ncoeff;
        emax = max(max(emax,abs(c(i,j) - b(i,j))));
        b(i,j) = c(i,j);
    end
end

% Use these coefficients to evaluate the solution.
npt = 9;
fprintf(['\n Solution evaluated at %d equally spaced points.\n\n', ...
    '      X'], npt);
for jeqn = 1:neqn
    fprintf('       Y(%1d)', jeqn);
end
fprintf('\n');

% Prepare to store results for plotting.
xarray = zeros(npt, 1);
yarray = zeros(npt, neqn);

for ipt = 1:npt
    xarray(ipt) = (x0*(npt-ipt) + x1*(ipt-1))/(npt-1);
    fprintf('%10.4f', xarray(ipt));
    for jeqn = 1:neqn
        [yarray(ipt, jeqn), ifail] = nag_fit_1dcheb_eval2(int64(ndegree), x0, x1, ...
            c(:,jeqn), int64(1), xarray(ipt));
        fprintf('%10.4f', yarray(ipt, jeqn));
    end
    fprintf('\n');
end
% Plot results.
fig = figure('Number', 'off');
display_plot(xarray, yarray);

function [x, a, rhs] = bdyc(ii, jj, a, ia, ia1, rhs)
% Evaluate coefficient functions and rhs of boundary conditions.

x = -1.0;
a(ii,jj) = 1.0;
if (ii == 2 && jj == 1)
    rhs = 3.0;
end
function [a, rhs] = coeff(x, ii, a, ia, ia1, rhs)
% Evaluate coefficient functions and rhs of differential equations.

global b x0 x1 ndegree % For communication with main routine.

if (ii <= 1)
    [z1, ifail] = nag_fit_1dcheb_eval2(int64(ndegree), x0, x1, b(:,1), int64(1), x);
    [z2, ifail] = nag_fit_1dcheb_eval2(int64(ndegree), x0, x1, b(:,2), int64(1), x);
    a(1,1) = z2*z2 - 1.0;
    a(1,2) = 2.0;
    a(2,1) = 2.0*z1*z2 + 1.0;
    rhs = 2.0*z1*z2*z2;
else
    a(1,2) = -1.0;
    a(2,3) =  2.0;
end
function display_plot(x, y)
% Formatting for title and axis labels.
titleFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 14};
labFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 13};
set(gca, 'FontSize', 13); % for legend, axis tick labels, etc.
% Plot both curves.
[haxes, hline1, hline2] = plotyy(x, y(:,1), x, y(:,2));
% Set the axis limits and the tick specifications to beautify the plot.
set(haxes(1), 'YLim', [-0.5 0.05]);
set(haxes(1), 'YMinorTick', 'on');
set(haxes(1), 'YTick', [-0.5 -0.4 -0.3 -0.2 -0.1 0.0]);
set(haxes(2), 'YLim', [2.5 3.05]);
set(haxes(2), 'YMinorTick', 'on');
set(haxes(2), 'YTick', [2.5 2.6 2.7 2.8 2.9 3.0]);
for iaxis = 1:2
    % These properties must be the same for both sets of axes.
    set(haxes(iaxis), 'XLim', [-1 1]);
    set(haxes(iaxis), 'FontSize', 13);
end
% Add title.
title('Solution of Linearised System by Chebyshev Collocation', ...
    titleFmt{:});
% Label the axes.
xlabel('x', labFmt{:});
ylabel(haxes(1), 'y1', labFmt{:});
ylabel(haxes(2), 'y2', labFmt{:});
% Add a legend.
legend('y1','y2','Location','Best')
% Set some features of the three lines.
set(hline1, 'Linewidth', 0.25, 'Marker', '+', 'Line', '-');
set(hline2, 'Linewidth', 0.25, 'Marker', 'x', 'Line', '--');
 
nag_ode_bvp_coll_nth_comp example program results

 Iteration 1. Chebyshev coefficients are:
 -0.5659 -0.1162  0.0906 -0.0468  0.0196 -0.0069  0.0021 -0.0006  0.0001
  5.7083 -0.1642 -0.0087  0.0059 -0.0025  0.0009 -0.0003  0.0001 -0.0000

 Iteration 2. Chebyshev coefficients are:
 -0.6338 -0.1599  0.0831 -0.0445  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6881 -0.1792 -0.0144  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Iteration 3. Chebyshev coefficients are:
 -0.6344 -0.1604  0.0828 -0.0446  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6880 -0.1793 -0.0145  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Iteration 4. Chebyshev coefficients are:
 -0.6344 -0.1604  0.0828 -0.0446  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6880 -0.1793 -0.0145  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Solution evaluated at 9 equally spaced points.

      X       Y(1)       Y(2)
   -1.0000    0.0000    3.0000
   -0.7500   -0.2372    2.9827
   -0.5000   -0.3266    2.9466
   -0.2500   -0.3640    2.9032
    0.0000   -0.3828    2.8564
    0.2500   -0.3951    2.8077
    0.5000   -0.4055    2.7577
    0.7500   -0.4154    2.7064
    1.0000   -0.4255    2.6538

function d02tg_example
global b x0 x1 ndegree % For communication with coeff.

% Initialize variables and arrays.
x0 = -1;
x1 = 1;
ncolloc = 15;
neqn = 2;
ncoeff = 9;

nderiv = [1; 2];
nbc = [1; 2];

% Set initial values for Chebyshev series coefficients.
b = zeros(ncoeff, neqn);
b(1,2) = 6.0;

% The degree of the Chebyshev polynomial (as used in e02ak) is one less
% than the number of coefficients (as used in d02tg).
ndegree = ncoeff-1;

fprintf('d02tg example program results\n');

% Initial iteration.
iter = 1;
[c, ifail] = d02tg(int64(nderiv), int64(nbc), x0, x1, int64(ncoeff), ...
    int64(ncolloc), @coeff, @bdyc, 'n', int64(neqn));
if ifail ~= 0
    % Unsuccessful call.  Print message and exit.
    error('Warning: d02tg returned with ifail = %1d ',ifail);
end

% Output new estimate for coefficients.
fprintf(['\n Iteration ', num2str(iter), ...
    '. Chebyshev coefficients are:\n']);
for j = 1:neqn
    for i = 1:ncoeff
        fprintf('%8.4f',c(i,j));
    end
    fprintf('\n');
end

% Calculate change in coefficients.
emax = 0.0;
for j = 1:neqn; i = 1:ncoeff;
    emax = max(max(emax,abs(c(i,j) - b(i,j))));
    b(i,j) = c(i,j);
end

% Iterate until the change is small enough.
while emax >= 1.0e-05
    iter = iter + 1;

    [c, ifail] = d02tg(int64(nderiv), int64(nbc), x0, x1, ...
        int64(ncoeff), int64(ncolloc), @coeff, @bdyc, ...
        'n', int64(neqn));
    if ifail ~= 0
        % Unsuccessful call.  Print message and exit.
        error('Warning: d02tg returned with ifail = %1d ',ifail);
    end

    % Output coefficients.
    fprintf(['\n Iteration ', num2str(iter), ...
        '. Chebyshev coefficients are:\n']);
    for j = 1:neqn
        for i = 1:ncoeff
            fprintf('%8.4f',c(i,j));
        end
        fprintf('\n');
    end

    emax = 0.0;
    for j = 1:neqn; i = 1:ncoeff;
        emax = max(max(emax,abs(c(i,j) - b(i,j))));
        b(i,j) = c(i,j);
    end
end

% Use these coefficients to evaluate the solution.
npt = 9;
fprintf(['\n Solution evaluated at %d equally spaced points.\n\n', ...
    '      X'], npt);
for jeqn = 1:neqn
    fprintf('       Y(%1d)', jeqn);
end
fprintf('\n');

% Prepare to store results for plotting.
xarray = zeros(npt, 1);
yarray = zeros(npt, neqn);

for ipt = 1:npt
    xarray(ipt) = (x0*(npt-ipt) + x1*(ipt-1))/(npt-1);
    fprintf('%10.4f', xarray(ipt));
    for jeqn = 1:neqn
        [yarray(ipt, jeqn), ifail] = e02ak(int64(ndegree), x0, x1, ...
            c(:,jeqn), int64(1), xarray(ipt));
        fprintf('%10.4f', yarray(ipt, jeqn));
    end
    fprintf('\n');
end
% Plot results.
fig = figure('Number', 'off');
display_plot(xarray, yarray);

function [x, a, rhs] = bdyc(ii, jj, a, ia, ia1, rhs)
% Evaluate coefficient functions and rhs of boundary conditions.

x = -1.0;
a(ii,jj) = 1.0;
if (ii == 2 && jj == 1)
    rhs = 3.0;
end
function [a, rhs] = coeff(x, ii, a, ia, ia1, rhs)
% Evaluate coefficient functions and rhs of differential equations.

global b x0 x1 ndegree % For communication with main routine.

if (ii <= 1)
    [z1, ifail] = e02ak(int64(ndegree), x0, x1, b(:,1), int64(1), x);
    [z2, ifail] = e02ak(int64(ndegree), x0, x1, b(:,2), int64(1), x);
    a(1,1) = z2*z2 - 1.0;
    a(1,2) = 2.0;
    a(2,1) = 2.0*z1*z2 + 1.0;
    rhs = 2.0*z1*z2*z2;
else
    a(1,2) = -1.0;
    a(2,3) =  2.0;
end
function display_plot(x, y)
% Formatting for title and axis labels.
titleFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 14};
labFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 13};
set(gca, 'FontSize', 13); % for legend, axis tick labels, etc.
% Plot both curves.
[haxes, hline1, hline2] = plotyy(x, y(:,1), x, y(:,2));
% Set the axis limits and the tick specifications to beautify the plot.
set(haxes(1), 'YLim', [-0.5 0.05]);
set(haxes(1), 'YMinorTick', 'on');
set(haxes(1), 'YTick', [-0.5 -0.4 -0.3 -0.2 -0.1 0.0]);
set(haxes(2), 'YLim', [2.5 3.05]);
set(haxes(2), 'YMinorTick', 'on');
set(haxes(2), 'YTick', [2.5 2.6 2.7 2.8 2.9 3.0]);
for iaxis = 1:2
    % These properties must be the same for both sets of axes.
    set(haxes(iaxis), 'XLim', [-1 1]);
    set(haxes(iaxis), 'FontSize', 13);
end
% Add title.
title('Solution of Linearised System by Chebyshev Collocation', ...
    titleFmt{:});
% Label the axes.
xlabel('x', labFmt{:});
ylabel(haxes(1), 'y1', labFmt{:});
ylabel(haxes(2), 'y2', labFmt{:});
% Add a legend.
legend('y1','y2','Location','Best')
% Set some features of the three lines.
set(hline1, 'Linewidth', 0.25, 'Marker', '+', 'Line', '-');
set(hline2, 'Linewidth', 0.25, 'Marker', 'x', 'Line', '--');
 
d02tg example program results

 Iteration 1. Chebyshev coefficients are:
 -0.5659 -0.1162  0.0906 -0.0468  0.0196 -0.0069  0.0021 -0.0006  0.0001
  5.7083 -0.1642 -0.0087  0.0059 -0.0025  0.0009 -0.0003  0.0001 -0.0000

 Iteration 2. Chebyshev coefficients are:
 -0.6338 -0.1599  0.0831 -0.0445  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6881 -0.1792 -0.0144  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Iteration 3. Chebyshev coefficients are:
 -0.6344 -0.1604  0.0828 -0.0446  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6880 -0.1793 -0.0145  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Iteration 4. Chebyshev coefficients are:
 -0.6344 -0.1604  0.0828 -0.0446  0.0193 -0.0071  0.0023 -0.0006  0.0001
  5.6880 -0.1793 -0.0145  0.0053 -0.0023  0.0008 -0.0003  0.0001 -0.0000

 Solution evaluated at 9 equally spaced points.

      X       Y(1)       Y(2)
   -1.0000    0.0000    3.0000
   -0.7500   -0.2372    2.9827
   -0.5000   -0.3266    2.9466
   -0.2500   -0.3640    2.9032
    0.0000   -0.3828    2.8564
    0.2500   -0.3951    2.8077
    0.5000   -0.4055    2.7577
    0.7500   -0.4154    2.7064
    1.0000   -0.4255    2.6538


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