Computer >> Máy Tính >  >> Lập trình >> Python

Nâng chuỗi Hermite lên thành sức mạnh bằng Python

Để nâng một chuỗi Hermite lên thành lũy thừa, hãy sử dụng phương thức polynomial.hermite.hermpow () trong PythonNumpy. Phương thức này trả về chuỗi lũy thừa Hermite. Trả về chuỗi Hermite c được nâng lên thành power power. Đối số c là một dãy các hệ số được sắp xếp từ thấp đến cao. tức là [1,2,3] là các trang này P_0 + 2 * P_1 + 3 * P_2.

Tham số, c là mảng 1-D gồm các hệ số chuỗi Hermite được sắp xếp từ thấp đến cao. Theparameter, pow là Công suất mà chuỗi sẽ được nâng lên. Tham số, maxpower là công suất tối đa cho phép. Điều này chủ yếu là để hạn chế sự phát triển của chuỗi đến kích thước không thể quản lý được. Mặc định là 16.

Các bước

Đầu tiên, hãy nhập thư viện được yêu cầu -

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

Tạo mảng 1-D gồm các hệ số chuỗi Hermite -

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

Hiển thị mảng hệ số -

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

Kiểm tra các thứ nguyên -

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

Lấy Datatype -

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

Lấy hình dạng -

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

Để nâng chuỗi Hermite lên thành lũy thừa, hãy sử dụng phương thức polynomial.hermite.hermpow () trong PythonNumpy -

print("\nResult....\n",H.hermpow(c, 3))

Ví dụ

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

# Create 1-D arrays of Hermite 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 Hermite series to a power, use the polynomial.hermite.hermpow() method in Python Numpy
# The method returns Hermite series of power.
print("\nResult....\n",H.hermpow(c, 3))

Đầu ra

Our coefficient Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

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

Result....
   [2257. 2358. 3837. 908. 711. 54. 27.]