| Convention | Supported by: | |
| P11(x) = -sqrt(1-x2) |
This webpage Abramowitz & Stegun 1972 (?) eq. 8.6.6 Gradshteyn & Rhyzhik (8.752.1) Mathematica's LegendreP[l,m,z] function wolfram.mathworld.com | Includes Condon- Shortley phase |
| P1 1(x) = sqrt(1-x2) |
ciks.cbt.nist.gov Schaum's outline of mathematical functions | Condon-Shortley phase omitted |
| Plm(x) = (-1)m (1-x2)m/2 |
dm ---- dxm | Pl(x) |
| [1] |
| Plm(x) = (1-x2)m/2 |
dm ---- dxm | Pl(x) |
| [2] |
| Plm = (-1)m Plm |
| [3] |
| Pl-m(x) = (-1)m |
(l-m)! ------- (l+m)! | Plm(x) |
| [4] |
| Pll(x) = |
(-1)l (2l-1)! ------------- 2l-1(l-1)! | (1-x2)l/2 |
| [5] |
| Pl-l(x) = |
1 ------ 2 l l! | (1-x2)l/2 |
| [6] |
|
 d --- dθ | Pll(cos(θ)) = |
(-1)l (2l-1)! -------------- 2l-1(l-1)! | l (sin(θ))l-1 cos(θ) |
| [7] |
|
 d --- dθ | Pl-l(x) = |
1 ----- 2l l! | l (sin(θ))l-1 cos(θ) |
| [8] |
|
double PLm(int L,int m,double x) { // PLm associated Legendre function // Reference: http://ciks.cbt.nist.gov/~garbocz/paper134/node10.html // "Appendix A: List of associated Legendre functions" // Note that their sign convention differs from that of Wolfram. double PLm1=-1234.5,s,x2,x3,x4,x5,x6,x7,x8,s2,s3,s4,s5,s6,s7,s8; int am,floorhalfL,ik,ik2; double d3; x2=x*x; s = (-1.0)*sqrt(1-x2); // The factor of -1.0 has the effect of adding the Condon-Shortley phas s2=s*s; am=abs(m); if (am>L) {cout<<"* Error: PLm |m|>L *";exit(0);} if (L>=9) { // L >= 9 floorhalfL = L/2; // intentional integer division for (ik=0;ik<=L;ik++) plmc[ik]=0; for (ik=0;ik<=floorhalfL;ik++) { // ik if ((ik%2)==1) plmc[L-2*ik] = -1; else plmc[L-2*ik] = 1; plmc[L-2*ik]*= factlut[2*L-2*ik]; plmc[L-2*ik]/= factlut[L-ik]; plmc[L-2*ik]/= factlut[ik]; plmc[L-2*ik]/= factlut[L-2*ik]; } // ik d3=pow7(2.0,L,3); for (ik=0;ik<=L;ik++) plmc[ik]/=d3; // Take derivative am times: for (ik=0;ik plmc[0]=0; int minik2; minik2=((am-ik-1)/2)*2; if (minik2<0) minik2=0; minik2=minik2+(1+L-ik)%2; for (ik2=minik2;ik2 plmc[ik2]=plmc[ik2+1]*(ik2+1); plmc[ik2+1]=0; } // ik2 plmc[L-ik]=0; } // ik // Evaluate polynomial: PLm1 = plmc[L-am]; for (ik=L-am;ik>=2;ik=ik-2) { //,, PLm1 = x2*PLm1 + plmc[ik-2]; } //,, if (((L-am)%2)==1) PLm1=PLm1*x; // Multiply by prefactor: if (am>0) PLm1 = PLm1 * pow7(s,am,6); } // L >= 9 else { // L < 9 if (L>=3) { // >=3 x3=x2*x; s3=s2*s; x4=x3*x; s4=s3*s; if (L>=5) { // >=5 x5=x4*x; s5=s4*s; x6=x5*x; s6=s5*s; if (L>=7) { // >=7 x7=x6*x; s7=s6*s; x8=x7*x; s8=s7*s; if (L>=9) { // >=9 cout<<"* Error L>=9 here 5324 * ";exit(0); } // >=9 } // >=7 } // >=5 } // >=3 // Note: unlike us, in ciks.cbt.nist.gov webpage, s = sqrt(1-x*x). They omit C-S phase if (L==0) PLm1=1; else if (L==1) { // L=1 if (am==0) PLm1=x; else if (am==1) PLm1=s; } // L=1 else if (L==2) { // L=2 if (am==0) PLm1=0.5*(3*x2-1.0); else if (am==1) PLm1=3.0*x*s; else if (am==2) PLm1=3.0*s2; } // L=2 else if (L==3) { // L=3 if (am==0) PLm1=(1.0/2.0)*(5*x3-3.0*x); else if (am==1) PLm1=(3.0/2.0)*(5.0*x2-1.0)*s; else if (am==2) PLm1=15.0*x*s2; else if (am==3) PLm1=15.0*s3; } // L=3 else if (L==4) { // L=4 if (am==0) PLm1=(1.0/8.)*(35*x4-30*x2+3.0); else if (am==1) PLm1=2.5*(7*x3-3.0*x)*s; else if (am==2) PLm1=7.5*(7*x2-1)*s2; else if (am==3) PLm1=105.0*x*s3; else if (am==4) PLm1=105.0*s4; } // L=4 else if (L==5) { // L= 5 if (am==0) PLm1=(1.0/8.0)*(63*x5-70*x3+15*x); else if (am==1) PLm1=(15.0/8.0)*(21*x4-14*x2+1)*s; else if (am==2) PLm1=(105.0/2.0)*(3*x3-x)*s2; else if (am==3) PLm1=(105.0/2.0)*(9*x2-1)*s3; else if (am==4) PLm1=945.0*x*s4; else if (am==5) PLm1=945.0*s5; } // L= 5 else if (L==6) { // L= 6 if (am==0) PLm1=(1.0/16.0)*(231*x6-315*x4+105*x2-5); else if (am==1) PLm1=(21.0/8.0)*(33*x5-30*x3+5*x)*s; else if (am==2) PLm1=(105.0/8.0)*(33*x4-18*x2+1)*s2; else if (am==3) PLm1=(315.0/2.0)*(11*x3-3*x)*s3; else if (am==4) PLm1=(945.0/2.0)*(11*x2-1.0)*s4; else if (am==5) PLm1=10395.0*x*s5; else if (am==6) PLm1=10395.0*s6; } // L= 6 else if (L==7) { // L= 7 if (am==0) PLm1=(1.0/16.0)*(429*x7-693*x5+315*x3-35*x); else if (am==1) PLm1=(7.0/16.0)*(429*x6-495*x4+135*x2-5)*s; else if (am==2) PLm1=(63.0/8.0)*(143*x5-110*x3+15*x)*s2; else if (am==3) PLm1=(315.0/8.0)*(143*x4-66*x2+3)*s3; else if (am==4) PLm1=(3465.0/2.0)*(13*x3-3*x)*s4; else if (am==5) PLm1=(10395.0/2.0)*(13*x2-1)*s5; else if (am==6) PLm1=135135.0*x*s6; else if (am==7) PLm1=135135.0*s7; } // L= 7 else if (L==8) { // L= 8 if (am==0) PLm1=(1.0/128.0)*(6435*x8-12012*x6+6930*x4-1260*x2+35); else if (am==1) PLm1=(9.0/16.0)*x*(715*x6-1001*x4+385*x2-35)*s; else if (am==2) PLm1=(315.0/16.0)*(143*x6-143*x4+33*x2-1)*s2; else if (am==3) PLm1=(3465.0/8.0)*x*(39*x4-26*x2+3)*s3; else if (am==4) PLm1=(10395.0/8.0)*(65*x4-26*x2+1)*s4; else if (am==5) PLm1=(135135.0/2.0)*(5*x3-x)*s5; else if (am==6) PLm1=(135135.0/2.0)*(15*x2-1)*s6; else if (am==7) PLm1=2027025.0*x*s7; else if (am==8) PLm1=2027025.0*s8; } // L= 8 } // L < 9 if (m<0) { // m<0 PLm1 = PLm1*factlut[L-am]/factlut[L+am]; if ((am%2)==1) PLm1*=-1; } // m<0 // [ Strangely, PLm for plus m and minus m are not the same! ] // P L ^-m (x) = (-1)^m (L-m)!/(L+m)! P L ^m (x) // eq. (42) on http://mathworld.wolfram.com/LegendrePolynomial.html // Also eq (30) in http://ciks.cbt.nist.gov/~garbocz/paper134/node10.html // I am assuming that zero factorial is 1 in this. return PLm1; } // PLm associated Legendre function |