假想p球谐函数

2024-05-13 08:45:24 发布

您现在位置:Python中文网/ 问答频道 /正文

在scipy(http://docs.scipy.org/doc/scipy-0.15.0/reference/generated/scipy.special.sph_harm.html)的文档中,它清楚地说明了scipy.special.sph\U伤害返回一个复杂的浮点值。由链接中显示的表达式给出。但是,当尝试插入一些值时,我一直只得到期望值的一个微不足道的值。在

如果计算链接中的数学表达式,我认为实际值(即非想象值)更接近于预期的绝对值: 在

from scipy.special import sph_harm,lpmv
m=2;n=5;th=2.1;ph=0.4
print(sph_harm(m,n,th,ph))
#returns (0.36574435883734352+2.5429495084534193e-310j) (essentially no imag.part

def norm(m,n): #sqrt part
  return np.sqrt((2*n+1)/(4*np.pi) * \
    np.math.factorial(n-m)/np.math.factorial(n+m))
def ie(m,theta): #imaginary exponential part
  return np.exp(1j*m*theta)
out=norm(m,n)*ie(m,th)*lpmv(m,n,np.cos(ph)) #lpmv=legendre
print(out,abs(out))
#returns (-0.179310129764-0.31877392206j) 0.365744358837

sph\u harm有什么问题吗?还是我用错了?在

我使用的是scipyv0.15.1


Tags: 表达式链接defnpscipyoutphreturns