LEGENDRE_TR_MATRIX Computes matrix to produce Discrete Legendre Transform formula (4.4.18) pag. 118, Quarteroni-Valli, Springer 1997 [a]=legendre_tr_matrix(x) returns the matrix which maps the vector of physical uknowns of u at LGL nodes, to the vector of frequency unknowns with respect to Legendre expansion. (I_n u)(x)=\Sum_{k=0}^n u^*_k L_k(x) (*) where L_k(x) are the Legendre polynomials Input: x = array of np (Legendre Gauss Lobatto) LGL nodes on [-1,1] Output: a = matrix (np,np) associated to the map u_j ---> u^*_k Reference: A. Quarteroni, A. Valli: "Numerical Approximation of Partial Differential Equations" Springer Verlag / 1997 (2nd Ed)
0001 function [a]=legendre_tr_matrix(x); 0002 % LEGENDRE_TR_MATRIX Computes matrix to produce Discrete Legendre Transform 0003 % 0004 % formula (4.4.18) pag. 118, Quarteroni-Valli, Springer 1997 0005 % 0006 % [a]=legendre_tr_matrix(x) returns the matrix which maps the vector 0007 % of physical uknowns of u at LGL nodes, to the vector of frequency 0008 % unknowns with respect to Legendre expansion. 0009 % 0010 % (I_n u)(x)=\Sum_{k=0}^n u^*_k L_k(x) (*) 0011 % 0012 % where L_k(x) are the Legendre polynomials 0013 % 0014 % Input: x = array of np (Legendre Gauss Lobatto) LGL nodes on [-1,1] 0015 % 0016 % Output: a = matrix (np,np) associated to the map u_j ---> u^*_k 0017 % 0018 % Reference: A. Quarteroni, A. Valli: 0019 % "Numerical Approximation of Partial Differential Equations" 0020 % Springer Verlag / 1997 (2nd Ed) 0021 % 0022 0023 % Written by Paola Gervasio 0024 % $Date: 2007/04/01$ 0025 0026 np=length(x); 0027 n=np-1; 0028 a=zeros(np); 0029 nnp1=1/(n*np); 0030 0031 pn=pnleg_all(x,n); 0032 pn2=(pn(:,np)).^2; 0033 for k=0:n-1 0034 a(k+1,:)=(2*k+1)*nnp1*(pn(:,k+1))'./pn2'; 0035 end 0036 a(np,:)=1./(np.*(pn(:,np))'); 0037 0038 return