필터 지우기
필터 지우기

How do I specify m for orthpoly::legendre ?

조회 수: 3 (최근 30일)
Billy
Billy 2011년 6월 14일
I want to get the associated Legendre polynomials in mupad, but only the Legendre (not assoc.) are avail.
Is there a way to get this or can I call the MATLAB legendre func from Mupad?

채택된 답변

Billy
Billy 2011년 6월 14일
Using http://mathworld.wolfram.com/AssociatedLegendrePolynomial.html, you can express the associated legendre polynomials in terms of the unassoc ones:
use(orthpoly,legendre)
P := (l,m) -> piecewise(
[m>0, (-1)^m * (1-x^2)^(m/2) * diff( legendre( l, x ), x $ m ) ],
[m=0, legendre( l, x )],
[m<0, (-1)^(-m) * (l+m)!/(l-m)! * P( l,-m )] )

추가 답변 (1개)

Billy
Billy 2012년 5월 17일
In fact a better way to do this:
Define Legendre polynomials:
P := (n) -> 1/(2^n * n!) * diff( (x^2-1)^n, x $ n )
// and the associated legendre polynomials:
Plm := (l,m) -> ( 1 - x^2 )^(m/2) * diff( P(l), x $ m )
// The normalizing factor:
Klm := (l,m) -> sqrt( ( (2*l+1)/(4*PI) ) * ( ( (l-m)!) / ((l+m)!) ) )
// Finally, the spherical harmonics
Ylm := (l,m,t,p) -> piecewise(
[m>0, sqrt(2)*Klm(l,m) * (Plm(l,m)|x=cos(t)) * cos(m*p) ],
[m=0, Klm(l,m) * (Plm(l,m)|x=cos(t)) ],
[m<0, sqrt(2)*Klm(l,-m) * (Plm(l,-m)|x=cos(t)) *sin(-m*p) ]
)
// Generate a plot:
plot( plot::Spherical( [ abs( Ylm(4,0,t,p) ), p, t], p=0..2*PI, t=0..PI,
UMesh=60, VMesh=60, FillColorType=Flat, Color=[.8,.5,.2] ), Scaling=Constrained )
// truncate values greater than 0
lt0 := (v) -> (1-heaviside(v)) * v
// truncate values less than 0
gt0 := (v) -> heaviside(v)*v
// plot
plot(
plot::Spherical( [ abs(gt0(Ylm(5,4,t,p))), p, t], p=0..2*PI, t=0..PI,
UMesh=60, VMesh=60, FillColorType=Flat, Color=[0,.6,0] ),
plot::Spherical( [ abs(lt0(Ylm(5,4,t,p))), p, t], p=0..2*PI, t=0..PI,
UMesh=60, VMesh=60, FillColorType=Flat, Color=[.4,0,.0] ),
Scaling=Constrained
)
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 5월 17일
(Note: the above is MuPAD code and must be run from within a MuPad notepad, or coded carefully into an evalin(symengine) call, or written to a file and the file called upon within MuPAD)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by