Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Python에서 Legendre 시리즈를 강력하게 키우기

<시간/>

르장드르 시리즈를 거듭제곱하려면 PythonNumpy에서 polynomial.legendre.legpow() 메서드를 사용하세요. 이 메서드는 멱승으로 올린 르장드르 급수 c를 반환합니다. 인수 c는 낮은 것에서 높은 것으로 정렬된 계수의 시퀀스입니다. 즉, [1,2,3]은 시리즈 P_0 + 2*P_1 + 3*P_2입니다. 르장드르 시리즈 c를 거듭제곱으로 올린 값을 반환합니다. 인수 c는 낮은 것에서 높은 것으로 정렬된 계수의 시퀀스입니다. 즉, [1,2,3]은 시리즈 P_0 + 2*P_1 + 3*P_2입니다.

매개변수 c는 낮은 것에서 높은 것으로 정렬된 르장드르 급수 계수의 1차원 배열입니다. 매개변수, pow는 시리즈가 제기될 거듭제곱입니다. 매개변수 maxpower는 허용되는 최대 전력입니다. 이것은 주로 시리즈의 성장을 관리할 수 없는 크기로 제한하기 위한 것입니다. 기본값은 16

단계

먼저 필요한 라이브러리를 가져옵니다 -

import numpy as np
from numpy.polynomial import laguerre as L

Laguerre 급수 계수의 1차원 배열 생성 -

c = np.array([1,2,3])

계수 배열 표시 -

print("Our coefficient 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)

르장드르 급수를 거듭제곱하려면 PythonNumpy에서 polynomial.legendre.legpow() 메서드를 사용하세요 -

print("\nResult....\n",L.legpow(c, 3))

import numpy as np
from numpy.polynomial import legendre as L

# Create 1-D arrays of Laguerre series coefficients
c = np.array([1,2,3])

# Display the coefficient array
print("Our coefficient 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 raise a Legendre series to a power, use the polynomial.legendre.legpow() method in Python Numpy
# The method returns the Legendre series c raised to the power pow. The argument c is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series P_0 + 2*P_1 + 3*P_2.
print("\nResult....\n",L.legpow(c, 3))
입니다.

출력

Our coefficient Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(3,)

Result....
   [16.74285714 42.17142857 55.14285714 46.4 33.8025974 15.42857143 6.31168831]