Loading [MathJax]/jax/output/HTML-CSS/jax.js

2019년 2월 24일 일요일

파이썬 Sympy 기호수학 - 4. Legendre 다항식

파이썬 Sympy 기호수학 - 4. Legendre 다항식

SymPy 기호수학 - 4. Legendre 다항식

sympy 라이브러리를 불러오고, 사용할 기호 변수를 선언한다. 출력을 LaTex 수식으로 나타내고, 맷플롯립 모듈을 불러온다.

In [1]:
from sympy import *
          
x, y, z, t = symbols('x y z t')
f, g, h = symbols('f, g, h', cls=Function)

init_printing()
%matplotlib inline 

Legendre 방정식

Legendre 방정식은 다음과 같다.

(1x2)y2xy+n(n+1)y=0

n 은 정수이다.

Legendre 방정식은 편미분 방정식을 구형 좌표계로 표현할 때 나타난다.

Legendre 방정식의 해는 거듭제곱급수 해법을 사용하여 구한다.

Legendre 방정식의 해를 Pn(x) 로 나타내고, Legendre 다항식 (Legendre polynomial)이라 부른다.

P0(x)=1

P1(x)=x

P2(x)=12(3x21)

P3(x)=12(5x33x)

P4(x)=18(35x430x2+3)

Pn(1)=1 되도록 계수를 결정한다.

일반적인 표현으로 나타내면

Pn(x)=Mm=0(1)m(2n2m)!2nm!(nm)!(n2m)!xn2m

M={n2n=0,2,4,n12n=1,3,5,

P0(x),P1(x),P2(x),P3(x),P4(x) 를 확인해 본다.

legendre(n,x) 는 n차 Legendre 다항식을 구해준다.

In [2]:
legendre( 0, x )
Out[2]:
1
In [3]:
legendre( 1, x )
Out[3]:
x
In [4]:
legendre( 2, x )
Out[4]:
3x2212
In [5]:
legendre( 3, x )
Out[5]:
5x323x2
In [6]:
legendre( 4, x )
Out[6]:
35x4815x24+38

P0(x),P1(x),P2(x),P3(x),P4(x) 를 그래프로 그려보면

In [7]:
plot( legendre(0,x), legendre(1,x), legendre(2,x), legendre(3,x), legendre(4,x), 
     xlim=(-1.1,1.1), ylim=(-1.1,1.1) )
Out[7]:
<sympy.plotting.plot.Plot at 0x5a858d0>

버금 Legendre 방정식 (associated Legendre equation)

버금 Legendre 방정식은 다음과 같다.

(1x2)y2xy+[n(n+1)m21x2]y=0

n,m 은 정수이다.

버금 Legendre 방정식은 양자역학에서 나타난다.

버금 Legendre 방정식의 해는 Pmn(x) 로 나타내고, 버금 Legendre 함수라고 한다.

assoc_legendre(n,m,x) 는 (n,m)차 버금 Legendre 함수를 구해준다.

In [8]:
assoc_legendre(0,0, x )
Out[8]:
1
In [9]:
assoc_legendre(1,0, x )
Out[9]:
x
In [10]:
assoc_legendre(1,1, x )
Out[10]:
x2+1

댓글 없음:

댓글 쓰기

Numeric Analysis 4 - Numeric Linear Algebra

Numeric Analysis 4 - Numeric Linear Algebra Numeric Linear Algebra ¶ ...