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

หาปริพันธ์อนุกรม Chebyshev กำหนดค่าคงที่การปริพันธ์ใน Python

บทนำ

เมธอด chebyshev.chebint() อนุญาตให้กำหนดค่าคงที่การปริพันธ์ (integration constant k) ได้โดยตรงผ่านพารามิเตอร์ k

พารามิเตอร์ k

ค่าของปริพันธ์ครั้งแรกที่ศูนย์คือค่าแรกในลิสต์ ปริพันธ์ครั้งที่สองที่ศูนย์คือค่าที่สอง เป็นต้น ค่าเริ่มต้น k=[] ทั้งหมดเป็นศูนย์ หาก m=1 สามารถให้ค่าสเกลาร์เดียวได้

ตัวอย่าง: กำหนด k = 3

import numpy as np
from numpy.polynomial import chebyshev as C

c = np.array([1, 2, 3])
print("Our coefficient 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)

# ปริพันธ์พร้อมกำหนดค่าคงที่ k = 3
print("\nResult...\n", C.chebint(c, k=3))

ผลลัพธ์

Our coefficient Array... [1 2 3]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (3,)
Result... [ 3.5 -0.5  0.5  0.5]

เปรียบเทียบกับค่าเริ่มต้น k=0 ที่ให้ [0.5, -0.5, 0.5, 0.5] การเพิ่ม k=3 เปลี่ยนค่าสัมประสิทธิ์ตัวแรกจาก 0.5 เป็น 3.5