หากต้องการแปลงอนุกรมเชบิเชฟ (Chebyshev series) เป็นพหุนาม (polynomial) ให้ใช้เมธอด chebyshev.cheb2poly() ใน Python NumPy
แปลงอาร์เรย์ที่แทนสัมประสิทธิ์ของอนุกรมเชบิเชฟ เรียงจากอันดับต่ำสุดไปสูงสุด เป็นอาร์เรย์ของสัมประสิทธิ์ของพหุนามที่เทียบเท่า (เทียบกับ "standard basis") เรียงจากอันดับต่ำสุดไปสูงสุด
เมธอดคืนค่าอาร์เรย์ 1 มิติ ที่มีสัมประสิทธิ์ของพหุนามที่เทียบเท่า เรียงจากอันดับต่ำสุดไปสูงสุด
พารามิเตอร์
- c: อาร์เรย์ 1 มิติ ที่มีสัมประสิทธิ์ของอนุกรมเชบิเชฟ เรียงจากอันดับต่ำสุดไปสูงสุด
ขั้นตอนการใช้งาน
1. นำเข้าไลบรารีที่จำเป็น
import numpy as np
from numpy import polynomial as P
2. สร้างอาร์เรย์ด้วย numpy.array() (สัมประสิทธิ์เชบิเชฟ)
c = np.array([1, 2, 3, 4, 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. แปลงอนุกรมเชบิเชฟเป็นพหุนามด้วย chebyshev.cheb2poly()
print("\nResult (chebyshev to polynomial)...\n", P.chebyshev.cheb2poly(c))
ตัวอย่างโค้ดเต็ม
import numpy as np
from numpy import polynomial as P
# สร้างอาร์เรย์สัมประสิทธิ์เชบิเชฟ: 1·T₀ + 2·T₁ + 3·T₂ + 4·T₃ + 5·T₄
c = np.array([1, 2, 3, 4, 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)
# แปลงอนุกรมเชบิเชฟเป็นพหุนาม
print("\nResult (chebyshev to polynomial)...\n", P.chebyshev.cheb2poly(c))
ผลลัพธ์ที่ได้
Our Array...
[1 2 3 4 5]
Dimensions of our Array...
1
Datatype of our Array object...
int64
Shape of our Array object...
(5,)
Result (chebyshev to polynomial)...
[ 3. -10. -34. 16. 40.]
คำอธิบายเพิ่มเติม
อนุกรมเชบิเชฟต้นฉบับ: C(x) = 1·T₀(x) + 2·T₁(x) + 3·T₂(x) + 4·T₃(x) + 5·T₄(x)
พหุนามที่เทียบเท่า: P(x) = 3 - 10x - 34x² + 16x³ + 40x⁴
ความสัมพันธ์ระหว่างพหุนามเชบิเชฟกับพหุนามมาตรฐาน:
- T₀(x) = 1
- T₁(x) = x
- T₂(x) = 2x² - 1
- T₃(x) = 4x³ - 3x
- T₄(x) = 8x⁴ - 8x² + 1
การแปลงนี้เป็นการคำนวณเชิงเส้น (linear transformation) ระหว่าง basis ทางคณิตศาสตร์สองชุด
ฟังก์ชันคู่คือ chebyshev.poly2cheb() สำหรับแปลงจากพหุนามเป็นเชบิเชฟ (ดูบทความ ID: 1004095129)
ใช้ chebyshev.cheb2poly() แปลงอนุกรมเชบิเชฟ 1·T₀+2·T₁+3·T₂+4·T₃+5·T₄ เป็นพหุนาม ได้สัมประสิทธิ์ [3, -10, -34, 16, 40]