以下,就是通过定义式得来的复数域gamma函数,未使用近似算:
function ret=Gamma(z)
if isreal(z)
ret=gamma(z);
else
if real(z) >= 0
rt=@(x)(-1).^x ./ (gamma(x+1).*(x+z));
ret=integral(@(x)exp(-x).*x.^(z-1), 1, Inf)+sum(rt(0:172));
else
ret=pi./(Gamma(1-z).*sin(pi.*z));
end
end
end