<< RealTime3D`

Define and print associated Legendre functions

AL[n_, m_, 
        t_]  := (((-1))^(n + m)) ((((1 - t^2))^(m/2))/((2^n) n!)) D[(((1 - t^2))^n), {t, n + m}] // Expand

Do[Print[SubsuperscriptBox[P, n, m] // DisplayForm, " = ", 
        AL[n, m, t]], {n, 0, 5}, {m, 0, n}]

Define spherical harmonics

LP[n_, m_, φ_]  :=  
      AL[n, m, Cos[φ]] /. (1  -  Cos[φ]^2)^
            l_  ->  Sin[φ]^(2  l)

Y[n_, m_, φ_, θ_]  :=  
      LP[n, m, φ] Cos[m θ]

Plot spherical harmonics

\(\(SHPlot[n_, m_]\  := \ \((r\  = \ Y[n, m, φ, θ]; 

          X\  = \ \({x, y, z}\  = \ 
              r\ {Sin[φ]\ Cos[θ], 
                  Sin[φ]\ Sin[θ], 
                  Cos[φ]\ }\); 
Print[
            SubsuperscriptBox[Y, n, m] // 
              DisplayForm, "(φ , θ) = ", r]; 

          p = ParametricPlot3D[
              X, {φ, 0, π}, {θ, 0, 2  π}, 
              PlotPoints\  -> \ 100 {1, 1}, 
              Boxed\  -> \ False])\);\)\)

Do[Do[SHPlot[n, m], {m, 0, n}], {n, 0, 4}]