Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Spherical Harmonics in MATLAB

  1. Oct 22, 2008 #1
    I would appreciate some input about how to program spherical harmonics in Matlab.


    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 [tex]\Gamma^m_{l}(\Omega_{i})[/tex] is a spherical harmonic and [tex]\alpha^m_{l}[/tex] depends on l, m, and t.

    Is there a spherical harmonic function in Matlab? I couldn't find anything except the Legendre polynomials.
  2. jcsd
  3. Oct 22, 2008 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    The definition of the spherical harmonics are found here


    which are a product of the Associated Legendre functions and a phase factor...... this should be straight forward to program in MatLAB
  4. Oct 23, 2008 #3
    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

    [tex] \frac {d^{l+m}} {dx^{l+m}} (x^2-1)^l[/tex]
  5. Oct 25, 2008 #4

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    Do a search on the MATLAB site, they have an abundance of code for you to look at.....
  6. Oct 25, 2008 #5
    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.
  7. Oct 25, 2008 #6

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    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.
  8. Oct 26, 2008 #7
    thanks for the tips.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook