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

รวมชุด Hermite และกำหนดลำดับการรวมใน Python


หากต้องการรวมซีรี่ส์ Hermite ให้ใช้เมธอด hermite.hermint() ใน Python พารามิเตอร์ที่ 1 c isan array ของสัมประสิทธิ์อนุกรมเฮอร์ไมต์ ถ้า c เป็นแบบหลายมิติ แกนที่ต่างกันจะสัมพันธ์กับตัวแปรต่างๆ โดยมีระดับในแต่ละแกนที่กำหนดโดยดัชนีที่เกี่ยวข้อง พารามิเตอร์ที่ 2 m คือลำดับการรวม ต้องเป็นค่าบวก (ค่าเริ่มต้น:1). พารามิเตอร์ตัวที่ 3 k คือค่าคงที่การแอนอินเทเกรชัน ค่าของอินทิกรัลแรกที่ lbnd คือค่าแรกในรายการ ค่าของอินทิกรัลที่สองที่ lbnd คือค่าที่สอง ฯลฯ ถ้า k ==[] (ค่าเริ่มต้น) ค่าคงที่ทั้งหมดจะถูกตั้งค่าให้เป็นศูนย์ ถ้า m ==1 สามารถระบุสเกลาร์เดี่ยวแทนรายการได้

พารามิเตอร์ตัวที่ 4 lbnd คือขอบเขตล่างของอินทิกรัล (ค่าเริ่มต้น:0) พารามิเตอร์ที่ 5 scl คือ ascalar หลังจากการผสานรวมแต่ละครั้ง ผลลัพธ์จะถูกคูณด้วย scl ก่อนที่ค่าคงที่การรวมจะถูกเพิ่ม (ค่าเริ่มต้น:1). พารามิเตอร์ที่ 6 แกนคือแกนที่ใช้อินทิกรัล (ค่าเริ่มต้น:0).

ขั้นตอน

ขั้นแรก นำเข้าไลบรารีที่จำเป็น -

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

สร้างอาร์เรย์ของสัมประสิทธิ์ -

c = np.array([1,2,3])

แสดงอาร์เรย์ -

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 ให้ใช้เมธอด hermite.hermint() ใน Python −

print("\nResult...\n",H.hermint(c, m = 3))

ตัวอย่าง

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

# Create an array of coefficients
c = np.array([1,2,3])

# 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 integrate a Hermite series, use the hermite.hermint() method in Python
print("\nResult...\n",H.hermint(c, m = 3))

ผลลัพธ์

Our Array...
   [1 2 3]

Dimensions of our Array...
1

Datatype of our Array object...
int64

Shape of our Array object...
(3,)

Result...
   [ 0.125 -0.25 0.125 0.02083333 0.01041667 0.00625 ]