Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Đạo hàm chuỗi Hermite_e và nhân mỗi lần đạo hàm với scalar trong Python


Để đạo hàm chuỗi Hermite_e, dùng phương thức hermite_e.hermeder() trong Python. Tham số 1, c là mảng hệ số chuỗi Hermite_e. Nếu c đa chiều, các trục khác nhau tương ứng biến khác với degree mỗi trục cho bởi index tương ứng.

Tham số 2, m là số lần đạo hàm, phải non-negative (Default: 1). Tham số 3, scl là scalar. Mỗi lần đạo hàm nhân với scl. Kết quả cuối nhân với scl**m. Dùng cho linear change of variable (Default: 1). Tham số 4, axis là trục đạo hàm.

Các bước

Đầu tiên, import thư viện cần thiết:

import numpy as np
from numpy.polynomial import hermite_e as H

Tạo mảng hệ số:

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

Hiển thị mảng:

print("Our Array...\n", c)

Kiểm tra Dimensions:

print("\nDimensions of our Array...\n", c.ndim)

Lấy Datatype:

print("\nDatatype of our Array object...\n", c.dtype)

Lấy Shape:

print("\nShape of our Array object...\n", c.shape)

Đạo hàm chuỗi Hermite_e, dùng hermite_e.hermeder():

print("\nResult...\n", H.hermeder(c, scl = -1))

Ví dụ

import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of coefficients
c = np.array([1,2,3,4])
# 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 Hermite_e series, use the hermite_e.hermeder() method in Python
print("\nResult...\n", H.hermeder(c, scl = -1))

Kết quả

Our Array...   [1 2 3 4]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (4,)
Result...   [ -2. -6. -12.]