บทนำ
ในการคำนวณรากของอนุกรม Laguerre สามารถใช้เมธอด laguerre.lagroots() จาก NumPy คล้ายกับตัวอย่างก่อนหน้า แต่ใช้สัมประสิทธิ์เป็นจำนวนจริง
ขั้นตอนการทำงาน
1. นำเข้าไลบรารี
from numpy.polynomial import laguerre as L
2. คำนวณรากของอนุกรม
print("Result...\n", L.lagroots([0, 1, 2]))
3. ตรวจสอบชนิดข้อมูล
print("\nType...\n", L.lagroots([0, 1, 2]).dtype)
4. ตรวจสอบรูปร่าง
print("\nShape...\n", L.lagroots([0, 1, 2]).shape)
ตัวอย่างโค้ดสมบูรณ์
from numpy.polynomial import laguerre as L
# คำนวณรากของอนุกรม Laguerre
print("Result...\n", L.lagroots([0, 1, 2]))
# ตรวจสอบชนิดข้อมูล
print("\nType...\n", L.lagroots([0, 1, 2]).dtype)
# ตรวจสอบรูปร่าง
print("\nShape...\n", L.lagroots([0, 1, 2]).shape)
ผลลัพธ์ที่คาดหวัง
Result... [0.69722436 4.30277564] Type... float64 Shape... (2,)