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

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

คล้ายตัวอย่างก่อนหน้า แต่ x เป็นทูเพิล (5, 10, 15) ให้ผลลัพธ์เหมือนกัน

ขั้นตอน

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.]