Matlab 如何使用Gauss-Lobatto和Gauss-Laguerre求积码
我正在使用MATLAB和以下函数:Matlab 如何使用Gauss-Lobatto和Gauss-Laguerre求积码,matlab,numerical-integration,polynomial-approximations,Matlab,Numerical Integration,Polynomial Approximations,我正在使用MATLAB和以下函数: 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
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);
通过这个函数,我可以得到权重和节点,通过它们我可以集成我最喜欢的函数。例如,我可以调用lglnodes(400-1)
并获取N=400
的节点和权重。那么我有这个代码:
我想对Gauss-Laguerre(
GaussLaguerre(n,alpha)
函数)也这样做,但我无法理解如何使用输入获得与上述相同的权重。你能给我解释一下如何调整输入吗?如何设置n
和alpha
?Gauss Lobatto和Gauss Laguerre是两个不同积分的积分点/权重:
- Lobatto表示(-1,1)中的未加权积分
- 拉盖尔代表(0,infty),权重
x^alpha exp(-x)