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

Python에서 축 1에 대한 다차원 계수를 사용하여 Legendre 시리즈 미분

<시간/>

르장드르 계열을 구별하려면 Python에서 polynomial.laguerre.legder() 메서드를 사용합니다. 축을 따라 m번 미분된 르장드르 시리즈 계수 c를 반환합니다. 각 반복에서 결과에 scl이 곱해집니다.

첫 번째 매개변수 c는 르장드르 급수 계수의 배열입니다. c가 다차원인 경우 differentaxis는 해당 인덱스에 의해 제공된 각 축의 차수를 가진 다른 변수에 해당합니다. 두 번째 매개변수인 m은 취한 도함수의 수이며 음수가 아니어야 합니다. (기본값:1). 세 번째 매개변수인 scl은 스칼라입니다. 각 미분에 scl을 곱합니다. 최종 결과는 scl**m을 곱한 것입니다. 이것은 변수의 선형 변화에 사용하기 위한 것입니다. (기본값:1). 네 번째 매개변수인 axis는 도함수를 취하는 축입니다. (기본값:0).

단계

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

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

계수의 다차원 배열 생성 -

c = np.arange(4).reshape(2,2)

배열 표시 -

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에서 polynomial.laguerre.legder() 메서드를 사용합니다. 축을 따라 m번 미분된 르장드르 시리즈 계수 c를 반환합니다. 각 반복에서 결과는 scl −

로 곱해집니다.
print("\nResult...\n",L.legder(c, axis = 1))

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

# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)

# 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 differentiate a Legendre series, use the polynomial.laguerre.legder() method in Python
print("\nResult...\n",L.legder(c, axis = 1))

출력

Our Array...
   [[0 1]
   [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

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

Result...
   [[1.]
   [3.]]