Quantcast Spherical Harmonics in MATLAB Text - Physics Forums Library

PDA

View Full Version : Spherical Harmonics in MATLAB


scarecrow
Oct22-08, 06:44 PM
I would appreciate some input about how to program spherical harmonics in Matlab.

http://mathworld.wolfram.com/SphericalHarmonic.html

I want to program a double summation that looks like this.



G(\Omega_{1},t_{1}|\Omega_{0}) = \sum_{l=0}^\infty \sum_{m=-l}^l \alpha^m_{l}(t_{1}) [\Gamma^m_{l}(\Omega_{0})]^* \Gamma^m_{l}(\Omega_{1})


where \Gamma^m_{l}(\Omega_{i}) is a spherical harmonic and \alpha^m_{l} depends on l, m, and t.

Is there a spherical harmonic function in Matlab? I couldn't find anything except the Legendre polynomials.

Dr Transport
Oct22-08, 10:13 PM
The definition of the spherical harmonics are found here

http://en.wikipedia.org/wiki/Spherical_harmonics

which are a product of the Associated Legendre functions and a phase factor...... this should be straight forward to program in MatLAB

scarecrow
Oct23-08, 11:56 AM
This is a follow up question. I'm a beginner in Matlab, so please excuse my ignorance if these questions seem stupid. How would you program higher-order derivatives into for loops? Is there a syntax in Matlab for higher-order derivatives?

for l = 0:5
for m = -l:l

\frac {d^{l+m}} {dx^{l+m}} (x^2-1)^l

Dr Transport
Oct25-08, 09:58 AM
Do a search on the MATLAB site, they have an abundance of code for you to look at.....

eys_physics
Oct25-08, 11:56 AM
Hey
Derivatives can be approximated by differences which is done by the command diff(x,k) where "x" is a vector and k is the order. Hence k=1 corresponds to the first order derivative of x.
Maybe this can help you further.

Dr Transport
Oct25-08, 12:23 PM
Hey
Derivatives can be approximated by differences which is done by the command diff(x,k) where "x" is a vector and k is the order. Hence k=1 corresponds to the first order derivative of x.
Maybe this can help you further.

True, but you have to be very very careful with numerical derivatives (they are a local entity as opposed to numerical integration which is more global in nature). Many special functions are better evaluated using recurrence relations.

scarecrow
Oct26-08, 02:54 PM
thanks for the tips.