점 (x, y)에서 2차원 Hermite_e(에르미트_e) 급수를 평가하려면 Python NumPy의 hermite.hermeval2d() 메서드를 사용하면 됩니다. 이 메서드는 x와 y의 대응하는 값들이 이루는 점들에서 2차원 다항식의 값을 계산하여 반환합니다.
매개변수 설명
첫 번째 매개변수 (x, y): 2차원 급수가 평가될 점 (x, y)를 지정합니다. 이때 x와 y는 반드시 같은 shape(형태)를 가져야 합니다. 만약 x 또는 y가 리스트(list)나 튜플(tuple)이라면 먼저 ndarray로 변환되며, ndarray가 아닌 경우에는 스칼라(scalar)로 처리됩니다.
두 번째 매개변수 (C): 계수(coefficient) 배열입니다. 다중 차수(multidegree) i, j에 해당하는 항의 계수가 c[i, j]에 저장되도록 정렬되어 있습니다. 만약 c의 차원이 2보다 크다면, 나머지 인덱스들은 여러 개의 계수 집합을 나타내는 데 사용됩니다.
단계별 진행 과정
1. 필요한 라이브러리 임포트
import numpy as np
from numpy.polynomial import hermite_e as H
2. 1D 계수 배열 생성
c = np.array([3, 5])
3. 배열 출력하기
print("Our Array...\n",c)4. 배열의 차원 확인
print("\nDimensions of our Array...\n",c.ndim)5. 데이터 타입 확인
print("\nDatatype of our Array object...\n",c.dtype)6. 배열의 shape 확인
print("\nShape of our Array object...\n",c.shape)7. hermeval2d()로 2D Hermite_e 급수 평가
x와 y의 대응하는 값 쌍으로 구성된 점들에서 2차원 다항식의 값을 계산합니다.
print("\nResult...\n",H.hermeval2d([1,2],[1,2],c))전체 예제 코드
import numpy as np
from numpy.polynomial import hermite_e as H
# 1D 계수 배열 생성
c = np.array([3, 5])
# 배열 출력
print("Our Array...\n",c)
# 차원 확인
print("\nDimensions of our Array...\n",c.ndim)
# 데이터 타입 확인
print("\nDatatype of our Array object...\n",c.dtype)
# shape 확인
print("\nShape of our Array object...\n",c.shape)
# hermeval2d() 메서드로 점 (x, y)에서 2D Hermite_e 급수 평가
print("\nResult...\n",H.hermeval2d([1,2],[1,2],c))
실행 결과
Our Array...
[3 5]
Dimensions of our Array...
1
Datatype of our Array object...
int64
Shape of our Array object...
(2,)
Result...
[21. 34.]
위 실행 결과를 보면, 계수 배열 [3, 5]를 사용하여 점 (1, 1)과 (2, 2)에서 2D Hermite_e 급수를 평가한 결과 각각 21.0과 34.0이 출력된 것을 확인할 수 있습니다. 이처럼 hermeval2d() 메서드를 활용하면 복잡한 수학적 계산 없이도 손쉽게 2차원 에르미트 급수를 평가할 수 있습니다.