Home > Src > Level_0 > xwcgl.m

xwcgl

PURPOSE ^

XWCGL Computes nodes and weights of the Chebyshev-Gauss-Lobatto quadrature formula.

SYNOPSIS ^

function [x,w] = xwcgl(np,a,b)

DESCRIPTION ^

XWCGL  Computes nodes and weights of the Chebyshev-Gauss-Lobatto quadrature formula.

    [x,w]=xwcgl(np) returns the np weigths and nodes 
    of the corresponding Chebyshev Gauss-Lobatto quadrature 
    formula in the reference interval [-1,1].

    [x,w]=xwcgl(np,a,b) returns the NP weigths and the nodes 
    of the corresponding Chebyshev Gauss-Lobatto quadrature 
    formula in the  interval [a,b].

 Input: np = number of nodes
        a, b = extrema of the interval

 Output: x(np,1) = CGL nodes  (CHQZ2, (2.4.14), pag. 86)
         w(np,1) = CGL weigths (CHQZ2, (2.4.14), pag. 86)


 Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang,
                    "Spectral Methods. Fundamentals in Single Domains"
                    Springer Verlag, Berlin Heidelberg New York, 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,w] = xwcgl(np,a,b)
0002 %XWCGL  Computes nodes and weights of the Chebyshev-Gauss-Lobatto quadrature formula.
0003 %
0004 %    [x,w]=xwcgl(np) returns the np weigths and nodes
0005 %    of the corresponding Chebyshev Gauss-Lobatto quadrature
0006 %    formula in the reference interval [-1,1].
0007 %
0008 %    [x,w]=xwcgl(np,a,b) returns the NP weigths and the nodes
0009 %    of the corresponding Chebyshev Gauss-Lobatto quadrature
0010 %    formula in the  interval [a,b].
0011 %
0012 % Input: np = number of nodes
0013 %        a, b = extrema of the interval
0014 %
0015 % Output: x(np,1) = CGL nodes  (CHQZ2, (2.4.14), pag. 86)
0016 %         w(np,1) = CGL weigths (CHQZ2, (2.4.14), pag. 86)
0017 %
0018 %
0019 % Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang,
0020 %                    "Spectral Methods. Fundamentals in Single Domains"
0021 %                    Springer Verlag, Berlin Heidelberg New York, 2006.
0022 
0023 %   Written by Paola Gervasio
0024 %   $Date: 2007/04/01$
0025 
0026 
0027 if np <= 1 
0028   es='The number of the quadrature nodes should be greater than 1';
0029   disp(es); x = []; w = [];
0030   return 
0031 end 
0032 
0033 n=np-1;
0034 ww=pi/n;
0035 w=ww*ones(np,1);
0036 x(1:np,1)=-cos((0:n)'*ww);
0037 w(1)=w(1)*.5;
0038 w(np)=w(1);
0039 
0040 if nargin ==3
0041    bma=(b-a)*.5;
0042    bpa=(b+a)*.5;
0043    x=bma*x+bpa;
0044    w=w*bma;
0045 end
0046 
0047 return

Generated on Fri 21-Sep-2007 10:07:00 by m2html © 2003