使用 Python 計算給定復根的 Hermite_e 級數的根


要計算 Hermite_e 級數的根,可以使用 Python NumPy 中的 hermite_e.hermeroots() 方法。該方法返回級數根的陣列。如果所有根都是實數,則輸出也是實數,否則為複數。

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

步驟

首先,匯入所需的庫:

from numpy.polynomial import hermite_e as H

計算 Hermite_e 級數的根:

j = complex(0,1)
print("Result...\n",H.hermeroots((-j, j)))

獲取資料型別:

print("\nType...\n",H.hermeroots((-j, j)).dtype)

獲取形狀:

print("\nShape...\n",H.hermeroots((-j, j)).shape)

示例

from numpy.polynomial import hermite_e as H

# To compute the roots of a Hermite_e series, use the hermite_e.hermeroots() 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..

# The parameter, c is a 1-D array of coefficients.
j = complex(0,1)
print("Result...\n",H.hermeroots((-j, j)))

# Get the datatype
print("\nType...\n",H.hermeroots((-j, j)).dtype)

# Get the shape
print("\nShape...\n",H.hermeroots((-j, j)).shape)

輸出

Result...
   [1.+0.j]

Type...
complex128

Shape...
(1,)

更新於:2022年3月11日

102 次檢視

啟動你的職業生涯

完成課程獲得認證

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