Home > Src > Level_0 > xwcg.m

xwcg

PURPOSE ^

XWCG Computes nodes and weights of the Chebyshev-Gauss quadrature formula

SYNOPSIS ^

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

DESCRIPTION ^

XWCG     Computes  nodes and weights of the Chebyshev-Gauss quadrature formula

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

    [x,w]=xwcg(np,a,b) REturns the np weigths and the nodes 
    of the corresponding Chebyshev Gauss quadrature 
    formula in the  interval (a,b).

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

 Output: x(np,1) = CG nodes  (CHQZ2, (2.4.12), pag. 85)
         w(np,1) = CG weigths (CHQZ2, (2.4.12), pag. 85)


 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] = xwcg(np,a,b)
0002 %XWCG     Computes  nodes and weights of the Chebyshev-Gauss quadrature formula
0003 %
0004 %    [x,w]=xwcg(np) returns the np weigths and nodes
0005 %    of the corresponding Chebyshev Gauss quadrature
0006 %    formula in the reference interval (-1,1).
0007 %
0008 %    [x,w]=xwcg(np,a,b) REturns the np weigths and the nodes
0009 %    of the corresponding Chebyshev Gauss 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) = CG nodes  (CHQZ2, (2.4.12), pag. 85)
0016 %         w(np,1) = CG weigths (CHQZ2, (2.4.12), pag. 85)
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 n=np-1;
0028 if np<=1
0029   x=0;w=pi*(b-a)*.5;
0030   return
0031 end
0032 den=pi/(2*np);
0033 w=pi/np*ones(np,1);
0034 x(1:np,1)=-cos((2*(0:n)'+1)*den);
0035 
0036 %
0037 % mappatura su (a,b)
0038 %
0039 if nargin == 3
0040   bma=(b-a)*.5;
0041   bpa=(b+a)*.5;
0042   x=bma*x+bpa;
0043   w=w*bma;
0044 end
0045 return

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