다항식을 르장드르 시리즈로 변환하려면 Python Numpy의 legendre.poly2lag() 메서드를 사용합니다. 가장 낮은 차수에서 가장 높은 차수로 정렬된 다항식의 계수를 나타내는 배열을 최저에서 최고 학위. 이 메서드는 등가Legendre 계열의 계수를 포함하는 1차원 배열을 반환합니다. 매개변수 pol은 다항식 계수를 포함하는 1차원 배열입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
import numpy as np from numpy.polynomial import legendre as L
numpy.array() 메서드를 사용하여 배열 생성 -
c = np.array([1, 2, 3, 4, 5])
배열 표시 -
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) 다항식을 르장드르 급수로 변환하려면 Python Numpy에서 legendre.poly2lag() 메서드를 사용하십시오 -
print("\nResult (polynomial to legendre)...\n",L.poly2leg(c)) 예시
import numpy as np
from numpy.polynomial import legendre as L
# Create an array using the numpy.array() method
c = np.array([1, 2, 3, 4, 5])
# Display the array
print("Our Array...\n",c)
# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)
# Get the Shape
print("\nShape of our Array object...\n",c.shape)
# To convert a polynomial to a Legendre series, use the legendre.poly2lag() method in Python Numpy
print("\nResult (polynomial to legendre)...\n",L.poly2leg(c)) 출력
Our Array... [1 2 3 4 5] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (5,) Result (polynomial to legendre)... [3. 4.4 4.85714286 1.6 1.14285714]