为了掌握 Gauss-Laguerre 积分的窍门,我决定用数值计算以下积分,可以将其与已知的解析解进行比较:
结果如下图所示。结果仅在自变量的有限子范围内匹配解析解。显然需要更加小心以确保所有的数值解的收敛。也许积分例程必须用于较小的子范围?我的问题是,我怎样才能使 Gauss-Laguerre(或一般的 Gaussian Quadrature)适用于上述类型的问题,我需要解决方案对所有都是准确的?

import numpy as np
import matplotlib.pyplot as plt
def integrand(t, s):
return s ** 3 * np.exp(-(s ** 2) * t) * np.exp(t)
vintegrand = np.vectorize(integrand)
def integral(omega):
I = np.dot(vintegrand(ti, omega), wi)
return I
vintegral = np.vectorize(integral)
ti, wi, = np.polynomial.laguerre.laggauss(175)
s = np.linspace(-50, 50, 100)
Is = vintegral(s)
plt.plot(s, Is, "b", label="$I(s)$ numerical solution")
plt.plot(s, s, "r", label="$I(s) = s$ analytical solution")
plt.xlabel("$s$")
plt.legend()
plt.show()
