บทนำ
เมธอด chebyshev.chebint() ใน NumPy ใช้สำหรับหาปริพันธ์ (integrate) ของอนุกรม Chebyshev สามารถกำหนดขอบเขตล่าง (lower bound) ค่าคงที่การปริพันธ์ และพารามิเตอร์อื่นๆ ได้
พารามิเตอร์ของ chebint()
- c: อาร์เรย์สัมประสิทธิ์อนุกรม Chebyshev
- m: ออเดอร์ของการปริพันธ์ (ค่าเริ่มต้น 1) ต้องเป็นบวก
- k: ค่าคงที่การปริพันธ์ (Integration constant) ค่าเริ่มต้นเป็นศูนย์
- lbnd: ขอบเขตล่างของการปริพันธ์ (ค่าเริ่มต้น 0)
- scl: ตัวคูณสเกลหลังการปริพันธ์แต่ละครั้ง (ค่าเริ่มต้น 1)
- axis: แกนที่ทำการปริพันธ์ (ค่าเริ่มต้น 0)
ขั้นตอนตัวอย่าง
1. นำเข้าไลบรารี
import numpy as np
from numpy.polynomial import chebyshev as C
2. สร้างอาร์เรย์สัมประสิทธิ์และตรวจสอบคุณสมบัติ
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)
3. หาปริพันธ์พร้อมกำหนด lbnd = -2
print("\nResult...\n", C.chebint(c, lbnd=-2))
ตัวอย่างโค้ดสมบูรณ์
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)
# ปริพันธ์พร้อมกำหนดขอบเขตล่าง -2
print("\nResult...\n", C.chebint(c, lbnd=-2))
ผลลัพธ์
Our coefficient Array... [1 2 3]
Dimensions of our Array... 1
Datatype of our Array object... int64
Shape of our Array object... (3,)
Result... [ 8.5 -0.5 0.5 0.5]