Skip to content

LUXOPHIA/LUX.SphericalHarmonics

Repository files navigation

LUX.SphericalHarmonics

Spherical Harmonics Library for Delphi.

🟥 球面調和関数:Spherical Harmonics

🟩(複素数)球面調和関数:(Complex) Spherical Harmonics

$$\begin{aligned} Y_n^m(\theta,\phi) &= \sqrt{\frac{2n+1}{4\pi}\,\frac{(n-m)!}{(n+m)!}}\;P_n^m\left(\cos\theta\right)\;e^{\,i\,m\,\phi}\\\ &= \frac{1}{\sqrt{2\pi}}\;\tilde{P}_n^m\left(\cos\theta\right)\;e^{\,i\,m\,\phi}\\\ \end{aligned}$$
  • $P_n^m(x)$:Associated Legendre functions (ALFs)
  • $\tilde{P}_n^m(x)$:Normalized Associated Legendre functions (nALFs)

🟩 実球面調和関数:Real Spherical Harmonics

$$\overline{Y}_n^m(\theta,\phi) = \dfrac{1}{\sqrt{4\pi}}\, \begin{cases} \overline{P}_n^{|m|}\left(\cos\theta\right)\,\sin\left(|m|\,\phi\right) & m < 0\\\ \overline{P}_n^0\left(\cos\theta\right) & m = 0\\\ \overline{P}_n^m\left(\cos\theta\right)\,\cos\left(m\,\phi\right) & m > 0\\\ \end{cases}$$
  • $\overline{P}_n^m(x)$:Fully Normalized Associated Legendre functions (fnALFs)

🟥 ルジャンドル陪関数:Associated Legendre functions

ルジャンドル陪関数(Associated Legendre polynomials)は、ルジャンドル陪微分方程式(Associated Legendre Differential Equation):

$$\left(1-x^2\right)\,\frac{d^2}{dx^2}\,P_n^m(x)-2x\,\frac{d}{dx}\,P_n^m(x)+\biggl[n \left(n+1\right)-\frac{m^2}{1-x^2}\biggr]P_n^m(x)=0$$

$[-1,+1]$ における解であり、次式のように定義される。

$$\begin{aligned} P_{n}^{m}(x) &= (-1)^{m} (1 - x^2)^{m/2} \frac{d^m}{dx^m} P_{n}(x)\\\ &= \frac{(-1)^{m}}{2^{n} n!} (1 - x^2)^{m/2} \frac{d^{n + m}}{dx^{n + m}} (1 - x^2)^{n} \end{aligned}$$

🟩 低次の多項式

$$x = \cos\theta, \quad s = \sqrt{1-x^2} = \sin \theta$$
$n$ $m$ $P_n^m$
0 0 $P_0^0(x) = 1$
$n$ $m$ $P_n^m$
1 0 $P_1^0(x) = x$
1 1 $P_1^1(x) = -s$
$n$ $m$ $P_n^m$
2 0 $P_2^0(x) = \frac{1}{2}\,(3x^2 - 1)$
2 1 $P_2^1(x) = -3\,x\,s$
2 2 $P_2^2(x) = 3\,s^2$
$n$ $m$ $P_n^m$
3 0 $P_3^0(x) = \frac{1}{2}\,x\,(5x^2 - 3)$
3 1 $P_3^1(x) = -\frac{3}{2}\,(5x^2 - 1)\,s$
3 2 $P_3^2(x) = 15\,x\,s^2$
3 3 $P_3^3(x) = -15\,s^3$
$n$ $m$ $P_n^m$
4 0 $P_4^0(x) = \frac{1}{8}\,(35x^4 - 30x^2 + 3)$
4 1 $P_4^1(x) = -\frac{5}{2}\,s\,(7x^3 - 3x)$
4 2 $P_4^2(x) = \frac{15}{2}\,s^2\,(7x^2 - 1)$
4 3 $P_4^3(x) = -105\,x\,s^3$
4 4 $P_4^4(x) = 105\,s^4$
$n$ $m$ $P_n^m$
5 0 $P_5^0(x) = \frac{1}{8}\,x\,(63x^4 - 70x^2 + 15)$
5 1 $P_5^1(x) = -\frac{15}{8}\,s\,(21x^4 - 14x^2 + 1)$
5 2 $P_5^2(x) = \frac{105}{2}\,x\,s^2\,(3x^2 - 1)$
5 3 $P_5^3(x) = -\frac{105}{2}\,s^3\,(9x^2 - 1)$
5 4 $P_5^4(x) = 945\,x\,s^4$
5 5 $P_5^5(x) = -945\,s^5$
$n$ $m$ $P_n^m$
6 0 $P_6^0(x) = \frac{1}{16}\,(231x^6 - 315x^4 + 105x^2 - 5)$
6 1 $P_6^1(x) = -\frac{21}{8}\,x\,s\,(33x^4 - 30x^2 + 5)$
6 2 $P_6^2(x) = \frac{105}{8}\,s^2\,(33x^4 - 18x^2 + 1)$
6 3 $P_6^3(x) = -\frac{315}{2}\,x\,s^3\,(11x^2 - 3)$
6 4 $P_6^4(x) = \frac{945}{2}\,s^4\,(11x^2 - 1)$
6 5 $P_6^5(x) = -10395\,x\,s^5$
6 6 $P_6^6(x) = 10395\,s^6$
$n$ $m$ $P_n^m$
7 0 $P_7^0(x) = \frac{1}{16}\,x\,(429x^6 - 693x^4 + 315x^2 - 35)$
7 1 $P_7^1(x) = -\frac{7}{16}\,s\,(429x^6 - 495x^4 + 135x^2 - 5)$
7 2 $P_7^2(x) = \frac{63}{8}\,x\,s^2\,(143x^4 - 110x^2 + 15)$
7 3 $P_7^3(x) = -\frac{315}{8}\,s^3\,(143x^4 - 66x^2 + 3)$
7 4 $P_7^4(x) = \frac{3465}{2}\,x\,s^4\,(13x^2 - 3)$
7 5 $P_7^5(x) = -\frac{10395}{2}\,s^5\,(13x^2 - 1)$
7 6 $P_7^6(x) = 135135\,x\,s^6$
7 7 $P_7^7(x) = -135135\,s^7$
$n$ $m$ $P_n^m$
8 0 $P_8^0(x) = \frac{1}{128}\,(6435x^8 - 12012x^6 + 6930x^4 - 1260x^2 + 35)$
8 1 $P_8^1(x) = -\frac{9}{16}\,x\,s\,(715x^6 - 1001x^4 + 385x^2 - 35)$
8 2 $P_8^2(x) = \frac{315}{16}\,s^2\,(143x^6 - 143x^4 + 33x^2 - 1)$
8 3 $P_8^3(x) = -\frac{3465}{8}\,x\,s^3\,(39x^4 - 26x^2 + 3)$
8 4 $P_8^4(x) = \frac{10395}{8}\,s^4\,(65x^4 - 26x^2 + 1)$
8 5 $P_8^5(x) = -\frac{135135}{2}\,x\,s^5\,(5x^2 - 1)$
8 6 $P_8^6(x) = \frac{135135}{2}\,s^6\,(15x^2 - 1)$
8 7 $P_8^7(x) = -2027025\,x\,s^7$
8 8 $P_8^8(x) = 2027025\,s^8$

🟩 初項

🟦 $P_n^n(x)$

$$P_n^n(x) = (-1)^n\,(2n-1)!!\,(1-x^2)^{\frac{n}{2}}$$

Delphi (Object Pascal)

function ALFsPNN( const N:Integer; const X:Double ) :Double;
var
   S :Double;
   I :Integer;
begin
     S := Sqrt( 1 - Sqr( X ) );
     Result := 1;  // N = 0
     for I := 1 to N do Result := -Result * ( 2 * I - 1 ) * S;
end;

🟩 漸化式

Recurrence Relation
$P_n^m(x) = (2m+1)\,x\,P_{n-1}^m(x)\,, \quad n = m + 1$
$P_n^m(x) = \dfrac{1}{(2m+1)x}P_{n+1}^m(x)\,, \quad n = m$
$P_n^m(x) = \dfrac{(2m-1)x}{m}\,P_n^{m-1}(x) - \dfrac{n+m-1}{m}\,P_n^{m-2}(x)$
$P_n^m(x) = \dfrac{1}{(2m+1)x}\Bigl\lbrace(m+1)\,P_n^{m+1}(x) + (n+m)\,P_n^{m-1}(x)\Bigr\rbrace$
$P_n^m(x) = \dfrac{1}{n+m+1}\Bigl\lbrace(2m+3)x\,P_n^{m+1}(x) - (m+2)\,P_n^{m+2}(x)\Bigr\rbrace$
$P_n^m(x) = \dfrac{1}{n-m}\Bigl\lbrace (2n-1)\,x\,P_{n-1}^m(x)-(n+m-1)\,P_{n-2}^m(x)\Bigr\rbrace$
$P_n^m(x) = \dfrac{1}{(2n+1)\,x}\Bigl\lbrace (n+m)\,P_{n-1}^m(x)+(n-m+1)\,P_{n+1}^m(x)\Bigr\rbrace$
$P_n^m(x) = \dfrac{1}{n+m+1}\Bigl\lbrace (2n+3)\,x\,P_{n+1}^m(x)-(n-m+2)\,P_{n+2}^m(x)\Bigr\rbrace$

🟥 正規化ルジャンドル陪関数:Normalized Associated Legendre functions

$$\begin{gathered} \tilde{P}_n^m(x) = \sqrt{\dfrac{2n+1}{2}\,\dfrac{(n-m)!}{(n+m)!}}\,P_n^m(x)\\\ \int_{-1}^1\bigl[\tilde{P}_n^m(x)\bigr]^2\,dx = 1 \end{gathered}$$

🟩 初項

🟦 $\tilde{P}_n^n(x)$

$$\tilde{P}_n^n(x) = (-1)^n\,\sqrt{\frac{(2n+1)!!}{2^{\,n+1}\,n!}}\,(1-x^2)^{n/2}$$

Delphi (Object Pascal)

function NALFsPNN( const N:Integer; const X:Double ) :Double;
var
   S :Double;
   I :Integer;
begin
     S := Sqrt( 1 - Sqr( X ) );
     Result := 1/Sqrt(2);  // N = 0
     for I := 1 to N do Result := -Result * Sqrt( ( 2 * N + 1 ) / ( 2 * N ) ) * S;
end;

🟦 $\tilde{P}_n^0(\cos\theta) = \tilde{P}_n(\cos\theta)$

$$\tilde{P}_n(\cos \theta) = \begin{cases} \dfrac{A_n^0}{2} + \displaystyle\sum_{k=1}^{\tfrac{n}{2}} A_n^{\,2k}\,\cos\left(2k\,\theta\right), & \text{$n$ :even}, \\[1.0em] \displaystyle\sum_{k=0}^{\tfrac{n-1}{2}} A_n^{\,2k+1}\,\cos\Bigl\{\left(2k+1\right)\theta\Bigr\}, & \text{$n$ :odd}. \end{cases}$$ $$\begin{aligned} A_0^0 &= \sqrt{2}\\\ A_n^n &= \frac{\sqrt{(2n-1)(2n+1)}}{2n}\,A_{n-1}^{n-1}\\\ A_n^k &= \frac{(N-k-1)\,(N+k+2)}{(N-k)\,(N+k+1)}\,A_n^{k+2}\\\ \end{aligned}$$
🟪 $\frac{d}{d\theta}\,\tilde{P}_n^0(\cos\theta) = \frac{d}{d\theta}\,\tilde{P}_n(\cos\theta)$
$$\frac{d}{d\theta}\tilde{P}_n(\cos \theta) = \begin{cases} \displaystyle \sum_{k=1}^{\tfrac{n}{2}} -2k\,A_n^{\,2k}\,\sin\left(2k\,\theta\right), & \text{$n$ :even}, \\\ \displaystyle \sum_{k=0}^{\tfrac{n-1}{2}} -\left(2k+1\right)\,A_n^{\,2k+1}\,\sin\Bigl\{\left(2k+1\right)\theta\Bigr\}, & \text{$n$ :odd}. \end{cases}$$

🟦 $\tilde{P}_n^1(x)$

$$\begin{gathered} \begin{aligned} \tilde{P}_n^1(x) &= -\frac{\sqrt{1-x^2}}{\sqrt{n(n+1)}}\,\frac{d}{dx}\,\tilde{P}_n^0(x)\\\ &= -\frac{\sqrt{1-x^2}}{\sqrt{n(n+1)}}\,\frac{d\theta}{dx}\frac{d}{d\theta}\,\tilde{P}_n^0(\theta)\\\ &= -\frac{\sqrt{1-x^2}}{\sqrt{n(n+1)}}\,\frac{-1}{\sqrt{1-x^2}}\,\frac{d}{d\theta}\,\tilde{P}_n^0(\theta)\\\ &= \frac{1}{\sqrt{n(n+1)}}\,\frac{d}{d\theta}\,\tilde{P}_n^0(\theta)\\\ \end{aligned}\\\ \theta = \cos^{-1}\,x \end{gathered}$$

🟩 漸化式:Recurrence relation

🟦 2項間漸化式:2 term recurrence relation

$$\tilde{P}_n^m(x) = x\,\sqrt{2m+3}\,\tilde{P}_{n-1}^m(x), \quad n = m + 1$$

🟦 3項間漸化式:3 term recurrence relation

$$\begin{aligned} \tilde{P}_n^m(x) &= \sqrt{\dfrac{(2n+1)(2n-1)}{(n+m)(n-m)}}\,x\,\tilde{P}_{n-1}^m(x)\\\ &- \sqrt{\dfrac{(2n+1)(n+m-1)(n-m-1)}{(2n-3)(n+m)(n-m)}}\,\tilde{P}_{n-2}^m(x) \end{aligned}$$

🟦 4項間漸化式:4 term recurrence relation

$$\begin{aligned} \tilde{P}_n^m(x) &= \sqrt{\frac{(2n+1)(n+m-3)(n+m-2)}{(2n-3)(n+m-1)(n+m)}}\,\tilde{P}_{n-2}^{m-2}(x)\\[20pt] &- \sqrt{\frac{(n-m+1)(n-m+2)}{(n+m-1)(n+m)}}\,\tilde{P}_n^{m-2}(x)\\\ &+ \sqrt{\frac{(2n+1)(n-m-1)(n-m)}{(2n-3)(n+m-1)(n+m)}}\,\tilde{P}_{n-2}^m(x)\\\ \tilde{P}_n^m(x) &= 0, \quad n < m \end{aligned}$$

Delphi (Object Pascal)

    0     1     2   M
0 (P00)--P01--(P02)
    |     |     |
1  P10---P11---P12
    |     |     |
2 (P20)--P21--[P22]
N
function NALFsPNM22( const N,M:Integer; const P00,P02,P20:Double ) :Double;
var
   A00, A02, A20 :Double;
begin
     A00 := Sqrt( ( ( 2 * N + 1 ) * ( N + M - 3 ) * ( N + M - 2 ) )
                / ( ( 2 * N - 3 ) * ( N + M - 1 ) * ( N + M     ) ) );
     A02 := Sqrt( ( ( 2 * N + 1 ) * ( N - M - 1 ) * ( N - M     ) )
                / ( ( 2 * N - 3 ) * ( N + M - 1 ) * ( N + M     ) ) );
     A20 := Sqrt( (                 ( N - M + 1 ) * ( N - M + 2 ) )
                / (                 ( N + M - 1 ) * ( N + M     ) ) );
     Result := A00 * P00 + A02 * P02 - A20 * P20;
end;

🟥 完全正規化ルジャンドル陪関数:Fully Normalized Associated Legendre functions

$$\begin{gathered} \begin{aligned} \overline{P}_n^m(x) &= \sqrt{k\,(2n+1)\,\frac{(n-m)!}{(n+m)!}}\,P_n^m(x),\quad k = \begin{cases} 1 & m = 0\\\ 2 & m \neq 0 \end{cases}\\\ &= \sqrt{2k}\,\tilde{P}_n^m(x) \end{aligned}\\\ \int \bigl\lvert Y_{n,m}(\theta,\phi) \bigr\rvert^2 \, d\Omega = \int_{0}^{2\pi}\int_{0}^{\pi}\bigl\lvert Y_n^m(\theta,\phi)\bigr\rvert^2\,\sin\theta\,d\theta\,d\phi = 1 \end{gathered}$$

🟥 Reference

1962 🟩 TABLES OF NORMALIZED ASSOCIATED LEGENDRE POLYNOMIALS

1964 🟩 Handbook of Mathematical Functions With Formulas, Graphs, and Mathematical Tables

332 333 334 335 336

1990 🟩 On the computation of Legendre functions in spectral models

2002 🟩 A unified approach to the Clenshaw summation and the recursive computation of very high degree and order fully normalised associated Legendre functions

2015 🟩 Comparison of Computational Methods of Associated Legendre Functions

2016 🟩 高次高階のルジャンドル陪函数の計算

2024 🟩 Realizing the Calculation of a Fully Normalized Associated Legendre Function Based on an FPGA

About

Spherical Harmonics Library for Delphi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages