Legendre Functions

Legendre functions in mathematica are given by LegendreP[ℓ,x].

P[ℓ_,x_]=LegendreP[ℓ,x];

We start by looking at a few explcit expressions: note that the order ℓ Legendre function is a ℓth order polynomial

Do[Print["P[",el,"]=",LegendreP[el,x]],{el,0,5}]

We can plot a few of these: note the number of zeros and the symmetry under x->-x

el=12;

Plot[LegendreP[el,x],{x,-1,1}]

Or plotting a few together:

Plot[{LegendreP[0,x],LegendreP[1,x],LegendreP[2,x],LegendreP[3,x],LegendreP[4,x],LegendreP[5,x]},{x,-1,1}]

Let us check that they do indeed satisfy the Legendre equation:

(1-(x^2))D[P[ell,x],{x,2}]-2 x D[P[ell,x],x]+ ell(ell+1)P[ell,x]//FullSimplify

and that they are orthogonal

ell=12;

(((2ell+1)/2))Integrate[P[ell,x]P[ell+1,x],{x,-1,1}]

Associated Legendre Functions

The associated Legendre functions, ((Subscript[P, ell])^m)(x), are given by LegendreP[ell, m, x]. For example

LegendreP[2,1,x]

Plotting them we find  for example

ell=2;m=1;

Plot[LegendreP[ell,m,x],{x,-1,1}]

Clear[ell,m,x]

Let us check that the LegendreP[ell,m,x] do solve the correct differential equation:

D[(1-(x^2))D[LegendreP[ell,m,x],x],x]+(ell(ell+1)-((m^2)/(1-(x^2))))LegendreP[ell,m,x]//FullSimplify

Spherical Harmonics

Spherical harmonics, (Subscript[Y, lm])(θ,ϕ), are given by

SphericalHarmonicY[2,1,θ,ϕ]

We can plot their absolute value:

l=5;m=0;

ParametricPlot3D[Abs[SphericalHarmonicY[l,m,θ,ϕ]]{Sin[θ]Sin[ϕ],Sin[θ]Cos[ϕ],Cos[θ]},{θ,0,π},{ϕ,2 π,0},Mesh->None,PlotRange->All]

Are they in fact eigenfunctions of the Laplacian on the sphere?:

Clear[nn,mm]

nn=14;mm=8;

(1/(Sin[θ]))D[Sin[θ]D[SphericalHarmonicY[nn,mm,θ,ϕ],θ],θ]+(1/((Sin[θ])^2))D[SphericalHarmonicY[nn,mm,θ,ϕ],{ϕ,2}]+nn(nn+1)SphericalHarmonicY[nn,mm,θ,ϕ]//FullSimplify