เพื่อแปลงพหุนามเป็นชุด Hermite ให้ใช้เมธอด hermite_e.poly2herme() ใน Python Numpy แปลงอาร์เรย์ที่แสดง係數ของพหุนามที่เรียงจากอันดับต่ำสุดไปสูงสุด เป็นอาร์เรย์ของ係數ของชุด Hermite ที่เทียบเท่า เรียงจากอันดับต่ำสุดไปสูงสุด เมธอดคืนค่าอาร์เรย์ 1-D ที่มี係ของชุด Hermite ที่เทียบเท่า พารามิเตอร์ pol คืออาร์เรย์ 1-D ที่มี係ของพหุนาม
ขั้นตอน
ก่อนอื่น import ไลบรารีที่จำเป็น:
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)
ดึง datatype:
print("\nDatatype of our Array object...\n", c.dtype)
ดึง shape:
print("\nShape of our Array object...\n", c.shape)
แปลงพหุนามเป็นชุด Hermite ด้วย hermite_e.poly2herme():
print("\nResult (polynomial to hermite_e)...\n", H.poly2herme(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 polynomial to a Hermite series
print("\nResult (polynomial to hermite_e)...\n", H.poly2herme(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 (polynomial to hermite_e)... [19. 14. 33. 4. 5.]