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

แปลงพหุนามเป็นอนุกรมเฮอร์ไมท์ใน Python

เมธอด hermite.poly2herm() แปลงอาร์เรย์係ณพหุนามมาตรฐาน (เรียงจากดีกรีต่ำไปสูง) เป็นอาร์เรย์係ณอนุกรมเฮอร์ไมท์

ขั้นตอน

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

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)
print("\nResult (polynomial to hermite)...\n", H.poly2herm(c))

ตัวอย่างโค้ดสมบูรณ์

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

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)
print("\nResult (polynomial to hermite)...\n", H.poly2herm(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)... [6.25 4. 4.5 0.5 0.3125]