Python NumPy에서 독립 변수 x를 Hermite_e(에르미트E) 급수에 곱하려면 polynomial.hermite_e.hermemulx() 메서드를 사용하면 됩니다. 이 메서드는 곱셈 결과를 나타내는 배열을 반환하며, 주어진 Hermite_e 급수에 독립 변수 x를 곱한 새로운 계수 배열을 계산해 줍니다.
여기서 매개변수 c는 낮은 차수부터 높은 차수 순으로 정렬된 Hermite_e 급수 계수를 담고 있는 1차원 배열입니다.
단계별 진행 방법
1. 필요한 라이브러리 가져오기
먼저 NumPy와 Hermite_e 모듈을 임포트합니다.
import numpy as np from numpy.polynomial import hermite_e as H
2. 배열 생성하기
Hermite_e 급수의 계수로 사용할 배열을 생성합니다.
c = np.array([1, 2, 3])
3. 배열 정보 확인하기
생성한 배열과 그 속성들을 출력하여 확인합니다.
print("Our Array...\n", c)
# 차원(Dimension) 확인
print("\nDimensions of our Array...\n", c.ndim)
# 데이터 타입(Datatype) 확인
print("\nDatatype of our Array object...\n", c.dtype)
# 형상(Shape) 확인
print("\nShape of our Array object...\n", c.shape)4. hermemulx() 메서드로 x 곱하기
H.hermemulx() 메서드를 호출하여 Hermite_e 급수에 독립 변수 x를 곱합니다.
print("\nResult....\n", H.hermemulx(c))전체 예제 코드
import numpy as np
from numpy.polynomial import hermite_e as H
# 배열 생성
c = np.array([1, 2, 3])
# 배열 출력
print("Our Array...\n", c)
# 차원 확인
print("\nDimensions of our Array...\n", c.ndim)
# 데이터 타입 확인
print("\nDatatype of our Array object...\n", c.dtype)
# 형상 확인
print("\nShape of our Array object...\n", c.shape)
# hermemulx() 메서드로 Hermite_e 급수에 독립 변수 x 곱하기
print("\nResult....\n", H.hermemulx(c))실행 결과
Our Array...
[1 2 3]
Dimensions of our Array...
1
Datatype of our Array object...
int64
Shape of our Array object...
(3,)
Result....
[2. 7. 2. 3.]결과 해석
위 예제에서 입력 계수 배열 [1, 2, 3]은 다음 Hermite_e 급수를 나타냅니다.
P(x) = 1·He₀(x) + 2·He₁(x) + 3·He₂(x)
여기에 독립 변수 x를 곱하면 결과 계수가 [2. 7. 2. 3.]로 반환됩니다. 원래 3개의 계수를 가진 급수에 x를 곱하면 차수가 하나 증가하여 4개의 계수를 가진 배열이 되는 것을 확인할 수 있습니다. 이처럼 hermemulx() 메서드는 Hermite_e 다항식 연산에서 x 곱셈을 간편하게 처리해 주는 유용한 도구입니다.