주어진 근으로 Laguerre 시리즈를 생성하려면 PythonNumpy에서 laguerre.lagfromroots() 메서드를 사용하십시오. 이 방법은 계수의 1차원 배열입니다. 모든 근이 실수이면 out은 실수 배열이고 일부 근이 복소수이면 결과의 모든 계수가 실수인 경우에도 out은 복소수입니다. 매개변수 루트는 루트를 포함하는 시퀀스입니다.
단계
먼저 필요한 라이브러리를 가져옵니다 -
from numpy.polynomial import laguerre as L
주어진 근으로 Laguerre 급수를 생성하려면 laguerre.lagfromroots() 메서드를 사용하십시오 -
j = complex(0,1)
print("Result...\n",L.lagfromroots((-j, j))) 데이터 유형 가져오기 -
print("\nType...\n",L.lagfromroots((-j, j)).dtype) 모양 가져오기 -
print("\nShape...\n",L.lagfromroots((-j, j)).shape) 예시
from numpy.polynomial import laguerre as L
# To generate a Laguerre series with given roots, use the laguerre.lagfromroots() method in Python Numpy.
# The method is a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real.
# The parameter roots are the sequence containing the roots.
j = complex(0,1)
print("Result...\n",L.lagfromroots((-j, j)))
# Get the datatype
print("\nType...\n",L.lagfromroots((-j, j)).dtype)
# Get the shape
print("\nShape...\n",L.lagfromroots((-j, j)).shape) 가져오기 출력
Result... [ 3.+0.j -4.+0.j 2.-0.j] Type... complex128 Shape... (3,)