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

ประเมินค่าอนุกรมเฮอร์ไมท์ที่รายการจุด x ใน Python

ใช้ hermval() กับ x เป็นลิสต์ [5, 10, 15] และ係ณ [1, 2, 3]

ขั้นตอน

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

c = np.array([1, 2, 3])
x = [5, 10, 15]
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...\n", H.hermval(x, c))

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

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

c = np.array([1, 2, 3])
x = [5, 10, 15]
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...\n", H.hermval(x, c))

ผลลัพธ์

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