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

Tích phân chuỗi Hermite_e và đặt lower bound của integral trong Python


Để tích phân chuỗi Hermite_e, dùng phương thức hermite_e.hermeint() 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à bậc tích phân, phải dương (Default: 1).

Tham số 3, k là hằng số tích phân. Giá trị integral đầu tiên tại lbnd là giá trị đầu tiên trong list, integral thứ hai tại lbnd là giá trị thứ hai, v.v. Nếu k == [] (default), tất cả hằng số = 0. Nếu m == 1, một scalar đơn lẻ có thể dùng thay vì list. Tham số 4, lbnd là lower bound của integral (Default: 0). Tham số 5, scl là scalar. Sau mỗi tích phân, kết quả nhân với scl trước khi cộng hằng số tích phân (Default: 1). Tham số 6, axis là trục tích phân (Default: 0).

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])

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)

Tích phân chuỗi Hermite_e, dùng hermite_e.hermeint():

print("\nResult...\n", H.hermeint(c, lbnd = -2))

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])
# 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 integrate a Hermite_e series, use the hermite_e.hermeint() method in Python
print("\nResult...\n", H.hermeint(c, lbnd = -2))

Kết quả

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