在 Python 中計算具有給定復根的 Laguerre 級數的根


要計算 Laguerre 級數的根,請在 Python Numpy 中使用 laguerre.lagroots() 方法。該方法返回級數根的陣列。如果所有根都是實數,則輸出也是實數,否則它是複數。

根的估計值是作為伴隨矩陣的特徵值獲得的。遠離複平面原點的根由於級數在這些值的數值不穩定性而可能具有較大的誤差。具有大於 1 的重數的根也將顯示較大的誤差,因為在這些點附近級數的值對根的誤差相對不敏感。可以通過幾次牛頓法迭代來改進靠近原點的孤立根。引數 c 是一個 1-D 係數陣列。

步驟

首先,匯入所需的庫:

from numpy.polynomial import laguerre as L

要計算 Laguerre 級數的根,請在 Python Numpy 中使用 laguerre.lagroots() 方法:

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,)

更新於:2022年3月4日

123 次檢視

開啟您的職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.