I'm using MATLAB and this function:
function [x,w,P]=lglnodes(N)
% Truncation + 1
N1=N+1;
x=cos(pi*(0:N)/N)';
% Legendre Vandermonde Matrix
P=zeros(N1,N1);
xold=2;
while max(abs(x-xold))>eps
xold=x;
P(:,1)=1; P(:,2)=x;
for k=2:N
P(:,k+1)=( (2*k-1)*x.*P(:,k)-(k-1)*P(:,k-1) )/k;
end
x=xold-( x.*P(:,N1)-P(:,N) )./( N1*P(:,N1) );
end
w=2./(N*N1*P(:,N1).^2);
With this function, I get weights and nodes over which I can integrate my favorite functions. For example, I can call lglnodes(400 - 1) and get nodes and weights for N = 400. Then I have this code:
I would like to do the same with Gauss-Laguerre (GaussLaguerre(n, alpha) function), but I cannot understand how to use the inputs to get about the same weights as above. Can you explain to me how to tune the inputs? How to set n and alpha?
'n' is the number of your quadrature nodes. Alpha is the power of 'x' for a normal gauss laguerre quadrature of the form $$\int_0^{\infty}x^{\alpha}e^xf(x)dx=\sum_{i=1}^n \omega_i f(x_i)$$ I am using the same gauss laguerre code and I did some changes, if you are interested i can send them to you.