ในการคำนวณรากของชุด Laguerre ให้ใช้วิธีการ laguerre.lagroots() ใน Python Numpy วิธีการคืนค่าอาร์เรย์ของรากของชุดข้อมูล ถ้ารากทั้งหมดเป็นของจริง ผลลัพธ์ก็คือของจริงด้วย ไม่เช่นนั้นมันจะซับซ้อน
ค่าประมาณของรูทได้มาจากค่าลักษณะเฉพาะของเมทริกซ์ที่แสดงร่วม รูทที่อยู่ไกลจากทฤษฎีของระนาบเชิงซ้อนอาจมีข้อผิดพลาดอย่างมากเนื่องจากความไม่แน่นอนของตัวเลขของอนุกรมสำหรับค่าดังกล่าว รากที่มีหลายหลากมากกว่า 1 จะแสดงข้อผิดพลาดที่มากขึ้นเช่นกัน เนื่องจากค่าของอนุกรมใกล้จุดดังกล่าวค่อนข้างไม่ไวต่อข้อผิดพลาดในราก รากที่แยกออกมาใกล้จุดกำเนิดสามารถปรับปรุงได้ด้วยวิธีของนิวตันซ้ำๆ พารามิเตอร์ c คืออาร์เรย์ 1-D ของสัมประสิทธิ์
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
from numpy.polynomial import laguerre as L
ในการคำนวณรากของซีรีส์ Laguerre ให้ใช้วิธี laguerre.lagroots() ใน Python Numpy -
j = complex(0,1)
print("Result...\n",L.lagroots([-j, j])) รับประเภทข้อมูล:−
print("\nType...\n",L.lagroots([-j, j]).dtype) รับรูปร่าง -
print("\nShape...\n",L.lagroots([-j, j]).shape) ตัวอย่าง
from numpy.polynomial import laguerre as L
# To Compute the roots of a Laguerre series, use the laguerre.lagroots() method in Python Numpy.
# The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex..
j = complex(0,1)
print("Result...\n",L.lagroots([-j, j]))
# Get the datatype
print("\nType...\n",L.lagroots([-j, j]).dtype)
# Get the shape
print("\nShape...\n",L.lagroots([-j, j]).shape) ผลลัพธ์
Result... [0.+0.j] Type... complex128 Shape... (1,)