Associated legendre polynomials fail after certain degree

6 ビュー (過去 30 日間)
ailbeildce
ailbeildce 2017 年 12 月 16 日
Hi,
I am using legendre polynomials for an application on spherical harmonics. However the code
legendre(170,0.5)
where 170 is the degree/order fail, giving me Inf or NaN. Is this considered a bug or is there way to aid the issue using higher precision somehow?
Best

採用された回答

David Goodmanson
David Goodmanson 2017 年 12 月 19 日
Hi ailbeildce,
Try legendre(n,x,'norm') or legendre(n,x,'sch'). Each of these normalizes the associated legendre function slightly differently, and both leave out a factor in front that gets out of hand in a big way as m gets large [where m is the upper parameter in Pmn, 0<=m<=n, and m=0 corresponds to the usual Pn].
With either of those options, n can go up to at least 2400.
You can see what the factors are in 'doc legendre'. You will have to check, but I think the 'norm' option for Pmn gives you
Int{-1,1} Pmn(x)^2 dx = 1,
appropriate for spherical harmonics.
  3 件のコメント
David Goodmanson
David Goodmanson 2018 年 3 月 30 日
You're very welcome. I should probably know, but what is a PM feature?
Elvis Alexander Agüero Vera
Elvis Alexander Agüero Vera 2023 年 1 月 16 日
編集済み: Elvis Alexander Agüero Vera 2023 年 1 月 16 日
I guess he refers to a private mesage.
Somewhat related question: I also need to calculate with efficiency the derivatives of the legendre Polynomials. I would appreciate a fast way of computing that.
Also, why is it that
f = matlabFunction(diff(legendreP(50, x), x))
is so unstable for degrees greater than, say, 50?

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 12 月 16 日
If you have the symbolic toolbox you can work with it
  2 件のコメント
ailbeildce
ailbeildce 2017 年 12 月 17 日
編集済み: ailbeildce 2017 年 12 月 17 日
legendre() gives out more information than legendreP. Although I don't know if there's a way to generate Y_l^m where m!=0 with legendreP.
Walter Roberson
Walter Roberson 2017 年 12 月 17 日
For integer m you can see https://en.wikipedia.org/wiki/Associated_Legendre_polynomials#Definition_for_non-negative_integer_parameters_%E2%84%93_and_m which the formula given in terms of derivatives. As the different orders correspond to different numbers of derivatives of the Legendre polynomial, you can find the different orders in a loop.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by