I'm trying to understand the Spherical harmonics expansion in order to solve a more complex problem but the result I'm expecting from a very simple calculation is not correct. I have no clue why this is happening.
A bit of theory: It is well known that a function on the surface of a sphere () can be defined as an infinite sum of some constant coefficients and the spherical harmonics :
The spherical harmonics are defined as :
where are the associated Legendre polynomials.
An finally, the constant coefficients can be calculated (similarly to the Fourier transform) as follow:
The problem: Let's assume we have a sphere centered in where the function on the surface is equal to for all points . We want to calculate the constant coefficients and then calculate back the surface function by approximation. Since the calculation of the constant coefficients reduces to :
which numerically (in Python) can be approximated using:
def Ylm(l,m,theta,phi):
return scipy.special.sph_harm(m,l,theta,phi)
def flm(l,m):
phi, theta = np.mgrid[0:pi:101j, 0:2*pi:101j]
return Ylm(l,m,theta,phi).sum()
Then, by computing a band limited sum over I'm expecting to see when for any given point .
L = 20
f = 0
theta0, phi0 = 0.0, 0.0
for l in xrange(0,L+1):
for m in xrange(-l,l+1):
f += flm(l,m)*Ylm(l,m,theta0,phi0)
print f
but for it gives me and not . For it gives me
I know it seems more a Mathematics problem but the formulas should be correct. The problem seems being on my computation. It could be a really stupid mistake but I cannot spot it. Any suggestion?
Thanks
答案 0 :(得分:1)
球谐函数与内积正交(
)<f|g> = Integral( f(theta,phi)*g(theta,phi)*sin(theta)*dphi*dtheta)
所以你应该用
来计算系数 clm = Integral( Ylm( theta, phi) * sin(theta)*dphi*dtheta)