DERLG Spectral (Legendre Gauss) derivative matrix [d]=derlg(x,np) returns the spectral Legendre Gauss derivative matrix d at the np LG nodes X (in (-1,1)). np-1 is the polynomial degree used. Legendre Gauss (LG) grid Input: x = array of LG nodes on (-1,1) (computed by xwlg) np = number of LG nodes (=n+1, n=polynomial interpolation degree) Output: d = spectral derivative matrix 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 [d] = derlg(x,np) 0002 %DERLG Spectral (Legendre Gauss) derivative matrix 0003 % 0004 % [d]=derlg(x,np) returns the spectral Legendre Gauss derivative 0005 % matrix d at the np LG nodes X (in (-1,1)). np-1 is the polynomial 0006 % degree used. Legendre Gauss (LG) grid 0007 % 0008 % 0009 % Input: x = array of LG nodes on (-1,1) (computed by xwlg) 0010 % np = number of LG nodes (=n+1, n=polynomial interpolation degree) 0011 % 0012 % Output: d = spectral derivative matrix 0013 % 0014 % Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang, 0015 % "Spectral Methods. Fundamentals in Single Domains" 0016 % Springer Verlag, Berlin Heidelberg New York, 2006. 0017 0018 % Written by Paola Gervasio 0019 % $Date: 2007/04/01$ 0020 0021 0022 n=np-1; 0023 d=zeros(np); 0024 [p,pd] = jacobi_eval(x,np,0,0); 0025 for i=1:np 0026 for j=1:np 0027 if(i~=j) 0028 d(i,j)=pd(i,1)/(pd(j,1)*(x(i)-x(j))); 0029 elseif(i==j) 0030 d(i,j)=x(i)/(1-x(i)*x(i)); 0031 end 0032 end 0033 end 0034 0035 return