ohno / Antique.jl

Self-contained, well-tested, well-documented Analytical Solutions of Quantum Mechanical Equations.
https://ohno.github.io/Antique.jl/
MIT License
18 stars 3 forks source link

Definitions of associated Legendre polynomials #49

Closed ohno closed 1 month ago

ohno commented 2 months ago

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.

https://github.com/ohno/Antique.jl/blob/b4c10b531aa7a597b564578a2f51469376a5791d/src/HydrogenAtom.jl#L54-L56

https://github.com/ohno/Antique.jl/blob/b4c10b531aa7a597b564578a2f51469376a5791d/src/PoschlTeller.jl#L65-L67

lhapp27 commented 2 months ago

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 commented 1 month ago

Should be fixed now with the latest merge.

ohno commented 1 month ago

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 commented 1 month ago

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 commented 4 days ago

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 commented 3 days ago

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 commented 2 days ago

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 commented 2 days ago

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))