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

Python에서 하나의 Chebyshev 시리즈를 다른 시리즈에 추가

<시간/>

하나의 Chebyshev 시리즈를 다른 시리즈에 추가하려면 Python Numpy에서 polynomial.chebyshev.chebadd() 메서드를 사용합니다. 이 메서드는 합계의 체비쇼프 급수를 나타내는 배열을 반환합니다. 두 체비쇼프 급수 c1 + c2의 합을 반환합니다. 인수는 최하위 항에서 최상위 항으로 정렬된 계수 시퀀스입니다. 즉, [1,2,3]은 T_0 + 2*T_1 + 3*T_2 계열을 나타냅니다. 매개변수 c1 및 c2는 낮은 것에서 높은 순서로 정렬된 Chebyshev 급수 계수의 1차원 배열입니다.

단계

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

import numpy as np
from numpy.polynomial import chebyshev as C

체비쇼프 급수 계수의 1차원 배열 생성 -

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

계수 배열 표시 -

print("Array1...\n",c1)
print("\nArray2...\n",c2)

데이터 유형 표시 -

print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)

두 어레이의 차원을 확인하십시오 -

print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)

두 배열의 모양을 확인하십시오 -

print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)

하나의 Chebyshev 시리즈를 다른 시리즈에 추가하려면 Python Numpy에서 polynomial.chebyshev.chebadd() 메서드를 사용하십시오 -

print("\nResult (sum)....\n",C.chebadd(c1,c2))

예시

import numpy as np
from numpy.polynomial import chebyshev as C

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

# Display the arrays of coefficients
print("Array1...\n",c1)
print("\nArray2...\n",c2)

# Display the datatype
print("\nArray1 datatype...\n",c1.dtype)
print("\nArray2 datatype...\n",c2.dtype)

# Check the Dimensions of both the arrays
print("\nDimensions of Array1...\n",c1.ndim)
print("\nDimensions of Array2...\n",c2.ndim)

# Check the Shape of both the arrays
print("\nShape of Array1...\n",c1.shape)
print("\nShape of Array2...\n",c2.shape)

# To add one Chebyshev series to another, use the polynomial.chebyshev.chebadd() method in Python Numpy
print("\nResult (sum)....\n",C.chebadd(c1,c2))

출력

Array1...
[1 2 3]

Array2...
[3 2 1]

Array1 datatype...
int64

Array2 datatype...
int64

Dimensions of Array1...
1

Dimensions of Array2...
1

Shape of Array1...
(3,)

Shape of Array2...
(3,)

Result (sum)....
[4. 4. 4.]