Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definitions of associated Legendre polynomials #49

Closed
ohno opened this issue Apr 20, 2024 · 8 comments
Closed

Definitions of associated Legendre polynomials #49

ohno opened this issue Apr 20, 2024 · 8 comments
Assignees
Milestone

Comments

@ohno
Copy link
Owner

ohno commented Apr 20, 2024

There are 2 kind of definitions of associated Legendre polynomials. We need to look up modern definitions (e.g. DLMF, cppref, SpecialPolynomials.jl). It seems better to unify them to the better definitions in the major update to v1.0.0.

function P(model::HydrogenAtom, x; n=0, m=0)
return (1//2)^n * (1-x^2)^(m//2) * sum(j -> (-1)^j * factorial(2*n-2*j) // (factorial(j) * factorial(n-j) * factorial(n-2*j-m)) * x^(n-2*j-m), 0:Int(floor((n-m)/2)))
end

function P(model::PoschlTeller, x; n=0, m=0) # different definition from hydrogen atom: additional factor (-1)^m here
return (-1)^m * (1//2)^n * (1-x^2)^(m//2) * sum(j -> (-1)^j * factorial(2*n-2*j) // (factorial(j) * factorial(n-j) * factorial(n-2*j-m)) * x^(n-2*j-m), 0:Int(floor((n-m)/2)))
end

@ohno ohno added this to the v1.0.0 milestone Apr 20, 2024
@ohno ohno assigned ohno and lhapp27 Apr 20, 2024
@lhapp27
Copy link
Collaborator

lhapp27 commented Apr 24, 2024

In PoschlTeller I used the formula from https://en.wikipedia.org/wiki/Associated_Legendre_polynomials#Closed_Form. Where is the one in HydrogenAtom from?
I think it is no big problem to use the same definition, but the code needs to be adjusted slightly to compensate for that.

@lhapp27
Copy link
Collaborator

lhapp27 commented May 17, 2024

Should be fixed now with the latest merge.

@ohno
Copy link
Owner Author

ohno commented May 17, 2024

Thank you for your efforts. Please fix the doc strings.

I didn't answer the question. I refered cpprefjp. The C++ implementation reference seems to be Abramowitz's mathematical formulae. The definitions are

$$\begin{align} & P_l(x) = \frac{1}{2^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (x^2 - 1)^l, \\\ & P_l^m(x) = (1 - x^2)^{m/2} \frac{\mathrm{d}^m}{\mathrm{d}x^m} P_l(x), \\\ & P_l^m(x) = \frac{1}{2^l l!} (1-x^2)^{m/2} \sum_{j=0}^{\lfloor (l-m)/2 \rfloor} (-1)^j \frac{l! (2l-2j)!}{j! (l-j)! (l-m-2j)!} x^{l-m-2j}. \end{align}$$

The Wikipedia definitions are

$$\begin{align} & P_{l}(x)=\frac{1}{2^{l} l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (x^2 - 1)^l, \\\ & P_{l}^m(x)=(-1)^m (1-x^2)^{m / 2} \frac{\mathrm{d}^m}{\mathrm{d}x^m} P_{l}(x), \\\ & P_l^m(x)=(-1)^m \cdot 2^l \cdot (1-x^2)^{m / 2} \cdot \sum_{k=m}^l \frac{k!}{(k-m)!} \cdot x^{k-m} \cdot\binom{l}{k}\binom{\frac{l+k-1}{2}}{l}. \end{align}$$

I believe that DLMF is also one of the most orthodox reference. In the DLMF, the definition of Legendre polynomials is same:

$$\begin{align} P_{l}(x) &= \frac{1}{(-2)^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (1-x^2)^l \\\ &= \frac{1}{[(-1)(2)]^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} \left[(-1)(x^2 - 1)\right]^l \\\ &= \frac{1}{(-1)^l 2^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} \left[(-1)^l (x^2 - 1)^l \right] \\\ &= \frac{1}{2^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (x^2 - 1)^l. \end{align}$$

And the examples of DLMF match the results of testing. But I couldn't understand the definition of associated Legendre polynomials: https://dlmf.nist.gov/18.30#ii. I'll consider it again another day.

@ohno ohno reopened this May 17, 2024
ohno added a commit that referenced this issue May 29, 2024
@ohno
Copy link
Owner Author

ohno commented May 29, 2024

I gave up understanding the DLMF definition of associated Legendre polynomials. I'll add some information about Abramowitz's definitions.

The definitions of cpprefjp:

$$\begin{align} P_l(x) &= \frac{1}{2^l l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (x^2 - 1)^l, \\\ P_l^m(x) &= (1 - x^2)^{m/2} \frac{\mathrm{d}^m}{\mathrm{d}x^m} P_l(x) \\\ &= \frac{1}{2^l l!} (1-x^2)^{m/2} \sum_{j=0}^{\lfloor (l-m)/2 \rfloor} (-1)^j \frac{l! (2l-2j)!}{j! (l-j)! (l-m-2j)!} x^{l-m-2j}, \end{align}$$

are not same as Abramowitz's definitions (8.6.6) and (8.6.16). The Wikipedia definitions

$$\begin{align} P_{l}(x) &= \frac{1}{2^{l} l!} \frac{\mathrm{d}^l}{\mathrm{d}x^l} (x^2 - 1)^l, \\\ P_{l}^m(x) &= (-1)^m (1-x^2)^{m / 2} \frac{\mathrm{d}^m}{\mathrm{d}x^m} P_{l}(x) \\\ &= (-1)^m \cdot 2^l \cdot (1-x^2)^{m / 2} \cdot \sum_{k=m}^l \frac{k!}{(k-m)!} \cdot x^{k-m} \cdot\binom{l}{k}\binom{\frac{l+k-1}{2}}{l}, \end{align}$$

are same as Abramowitz's definitions (8.6.6) and (8.6.16).

According to Wikipedia, the definition of the spherical harmonics differs between acoustics and quantum mechanics. The famous quantum mechanics textbook, Messhiah's definitions (B.71), (B.72) and (B.93)

$$ P_l(u) = \frac{1}{2^l l!} \frac{\mathrm{d}^l}{\mathrm{~d} u^l}\left(u^2-1\right)^l $$

$$ P_l^m(u) = \left(1-u^2\right)^{\frac{1 m}{}} \frac{\mathrm{d}^m}{\mathrm{~d} u^m} P_l(u) $$

$$ Y_l^m(\theta, \varphi)=(-)^m\left[\frac{(2 l+1)}{4 \pi} \frac{(l-m)!}{(l+m)!}\right]^{\frac{1}{2}} P_l^m(\cos \theta) \mathrm{e}^{l m \varphi} $$

are same as our current definitions.

@ohno ohno closed this as completed May 29, 2024
@ohno
Copy link
Owner Author

ohno commented Jul 1, 2024

There are various definitions:

W. Greiner, QUANTUM MECHANICS An Introduction, Fourth Edition (Springer Berlin, 2001) pp.90,95,100

$$ P_l(x)=\frac{1}{2^l l!} \frac{\mathrm{d}^l}{\mathrm{~d} x^l}\left(x^2-1\right)^l \tag{5} $$

$$ P_n^m(x)=\left(1-x^2\right)^{m / 2} \frac{\mathrm{d}^m}{\mathrm{~d} x^m} P_n(x) \tag{38} $$

$$ Y_{l m}(\vartheta, \varphi)=\sqrt{\frac{2 l+1}{4 \pi} \frac{(l-m)!}{(l+m)!}} P_l^m(\cos \vartheta) \mathrm{e}^{\mathrm{i} m \varphi} \tag{27} $$

D. J. Griffiths, D. F. Schroeter, Introduction to Quantum Mechanics Third Edition (Cambridge University Press, 2018) pp.135,137

$$ P_{\ell}(x) \equiv \frac{1}{2^{\ell} \ell!}\left(\frac{d}{d x}\right)^{\ell}\left(x^2-1\right)^{\ell} \tag{4.28} $$

$$ P_{\ell}^m(x) \equiv(-1)^m\left(1-x^2\right)^{m / 2}\left(\frac{d}{d x}\right)^m P_{\ell}(x) \tag{4.27} $$

$$ Y_{\ell}^m(\theta, \phi)=\sqrt{\frac{(2 \ell+1)}{4 \pi} \frac{(\ell-m)!}{(\ell+m)!}} e^{i m \phi} P_{\ell}^m(\cos \theta) \tag{4.32} $$

@ohno
Copy link
Owner Author

ohno commented Jul 2, 2024

NIST Digital Library of Mathematical Functions. https://dlmf.nist.gov/, Release 1.2.1 of 2024-06-15. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, H. S. Cohl, and M. A. McClain, eds. http://dlmf.nist.gov/14.30.E1

$$ Y_{l, m}(\theta, \phi)=\left(\frac{(l-m)!(2 l+1)}{4 \pi(l+m)!}\right)^{1 / 2} \mathrm{e}^{\mathrm{i} m \phi} \mathrm{P}_l^m(\cos \theta) \tag{14.30.1} $$

@ohno
Copy link
Owner Author

ohno commented Jul 3, 2024

N4861, The draft of C++20, ISO/IEC 14882:2020

26.8.6.17 Legendre polynomials sf.cmath.legendre

$$\mathrm{P}_{\ell}(x) = \frac{1}{2^{\ell}} \frac{\mathrm{d}^{\ell}}{\ell x^{\ell}} (x^2-1)^{\ell}$$

26.8.6.2 Associated Legendre functions sf.cmath.assoc.legendre

$$\mathrm{P}_{\ell}{ }^m(x) = (1-x^2)^{m / 2} \frac{\mathrm{d}^m}{\mathrm{d}x^m} \mathrm{P}_{\ell}(x)$$

26.8.6.20 Spherical associated Legendre functions sf.cmath.sph.legendre

$$\mathrm{Y}_{\ell}^m(\theta, \phi) = (-1)^m \left[ \frac{(2 \ell+1)}{4 \pi} \frac{(\ell-m)!}{(\ell+m)!} \right]^{1 / 2} \mathrm{P}_{\ell}^m(\cos \theta) e^{i m \phi}$$

@ohno
Copy link
Owner Author

ohno commented Jul 3, 2024

SciPy

scipy.special.lpmv

$$P_v^m=(-1)^m\left(1-x^2\right)^{m / 2} \frac{d^m}{d x^m} P_v(x)$$

scipy.special.sph_harm

$$Y_n^m(\theta, \phi)=\sqrt{\frac{2 n+1}{4 \pi} \frac{(n-m)!}{(n+m)!}} e^{i m \theta} P_n^m(\cos (\phi))$$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants