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

ประเมินอนุกรม Hermite_e 2 มิติ ที่จุด (x,y) ด้วยอาร์เรย์สัมประสิทธิ์ 1D ใน Python


บทนำ

การประเมินค่าอนุกรม Hermite_e 2 มิติ (2D Hermite_e Series) ที่จุด (x, y) ใช้เมธอด hermite.hermeval2d() ใน NumPy เมธอดนี้คืนค่าของพหุนาม 2 มิติที่จุดที่สร้างจากคู่ของค่าที่สอดคล้องจาก x และ y

พารามิเตอร์

  • พารามิเตอร์ที่ 1 (x, y): อนุกรม 2 มิติประเมินที่จุด (x, y) โดย x และ y ต้องมีรูปร่างเท่ากัน
  • พารามิเตอร์ที่ 2 (C): อาร์เรย์สัมประสิทธิ์ที่เรียงลำดับที่ c[i,j] มีสัมประสิทธิ์ของพจน์ multi-degree i,j หาก c มีมิติ > 2 ดัชนีที่เหลือจะนับชุดสัมประสิทธิ์หลายชุด

ขั้นตอนการทำงาน

1. นำเข้าไลบรารี

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

2. สร้างอาร์เรย์สัมประสิทธิ์ 1D

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

3. แสดงอาร์เรย์

print("Our Array...\n", c)

4. ตรวจสอบมิติ

print("\nDimensions of our Array...\n", c.ndim)

5. ตรวจสอบชนิดข้อมูล

print("\nDatatype of our Array object...\n", c.dtype)

6. ตรวจสอบรูปร่าง

print("\nShape of our Array object...\n", c.shape)

7. ประเมินอนุกรม Hermite_e 2 มิติ

print("\nResult...\n", H.hermeval2d([1, 2], [1, 2], c))

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

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

# สร้างอาร์เรย์สัมประสิทธิ์ 1D
c = np.array([3, 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 2 มิติ
print("\nResult...\n", H.hermeval2d([1, 2], [1, 2], c))

ผลลัพธ์ที่คาดหวัง

Our Array...   [3 5]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (2,)
Result...   [21. 34.]