XWLG Computes nodes and weights of the Legendre-Gauss quadrature formula. [x,w]=xwlg(np) returns the np weigths and nodes of the corresponding Legendre Gauss quadrature formula in the reference interval (-1,1). [x,w]=xwlg(np,a,b) returns the np weigths and the nodes of the corresponding Legendre Gauss quadrature formula in the interval (a,b). Input: np = number of nodes a, b = extrema of the interval Output: x(np,1) = LG nodes (CHQZ2, (2.3.10), pag. 76) w(np,1) = LG weigths (CHQZ2, (2.3.10), pag. 76) 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.
0001 function [x,w] = xwlg(np,a,b) 0002 %XWLG Computes nodes and weights of the Legendre-Gauss quadrature formula. 0003 % 0004 % [x,w]=xwlg(np) returns the np weigths and nodes 0005 % of the corresponding Legendre Gauss quadrature 0006 % formula in the reference interval (-1,1). 0007 % 0008 % [x,w]=xwlg(np,a,b) returns the np weigths and the nodes 0009 % of the corresponding Legendre 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) = LG nodes (CHQZ2, (2.3.10), pag. 76) 0016 % w(np,1) = LG weigths (CHQZ2, (2.3.10), pag. 76) 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=2; 0030 return 0031 end 0032 x=jacobi_roots(np,0,0); 0033 w=2./(pnleg1(x,np).^2.*(1-x.^2)); 0034 0035 0036 0037 % 0038 % map on (a,b) 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 return