Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

แปลงชุด Hermite_e เป็นพหุนามใน Python


ในการแปลงชุด Hermite_e เป็นพหุนาม ให้ใช้เมธอด hermite_e.herme2poly() ใน PythonNumpy แปลงอาร์เรย์ที่แสดงสัมประสิทธิ์ของอนุกรม Hermite_e โดยเรียงลำดับจากระดับต่ำสุดไปสูงสุด เป็นอาร์เรย์ของสัมประสิทธิ์ของพหุนามเทียบเท่า (เทียบกับเกณฑ์ "มาตรฐาน") โดยเรียงลำดับจากระดับต่ำสุดไปสูงสุด วิธีการส่งกลับอาร์เรย์ 1-D ที่มีค่าสัมประสิทธิ์ของพหุนามเทียบเท่า (เทียบกับพื้นฐาน "มาตรฐาน") ที่เรียงลำดับจากเทอมต่ำสุดไปสูงสุด พารามิเตอร์ c คืออาร์เรย์ 1-D ที่มีค่าสัมประสิทธิ์อนุกรม Hermite โดยเรียงลำดับจากค่าต่ำสุดไปสูงสุด

ขั้นตอน

ขั้นแรก นำเข้าไลบรารีที่จำเป็น -

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

สร้างอาร์เรย์โดยใช้เมธอด numpy.array() -

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

แสดงอาร์เรย์ -

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)

ในการแปลงอนุกรม Hermite_e เป็นพหุนาม ให้ใช้เมธอด hermite_e.herme2poly() ใน Python -

print("\nResult (hermite_e to polynomial)...\n",H.herme2poly(c))

ตัวอย่าง

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

# Create an array using the numpy.array() method
c = np.array([1, 2, 3, 4, 5])

# 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 convert a Hermite_e series to a polynomial, use the hermite_e.herme2poly() method in Python Numpy
print("\nResult (hermite_e to polynomial)...\n",H.herme2poly(c))

ผลลัพธ์

Our Array...
   [1 2 3 4 5]

Dimensions of our Array...
1

Datatype of our Array object...
int64

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

Result (hermite_e to polynomial)...
   [ 13. -10. -27. 4. 5.]