在 Python 中計算 Hermite_e 級數的根


要計算 Hermite_e 級數的根,可以使用 Python Numpy 中的 hermite.hermroots() 方法。該方法返回級數根的陣列。如果所有根都是實數,則輸出也是實數,否則為複數。引數 c 是一個一維繫數陣列。

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

步驟

首先,匯入所需的庫:

import numpy as np
from numpy.polynomial import hermite_e as H

要計算 Hermite_e 級數的根,可以使用 Python Numpy 中的 hermite.hermroots() 方法:

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

獲取資料型別:

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

獲取形狀:

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

示例

from numpy.polynomial import hermite_e as H

# To compute the roots of a Hermite_e series, use the hermite.hermroots() 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.
print("Result...\n",H.hermeroots((-1, 0, 1)))

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

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

輸出

Result...
   [-1.41421356 1.41421356]

Type...
float64

Shape...
(2,)

更新於:2022年3月11日

瀏覽量:113

啟動您的職業生涯

透過完成課程獲得認證

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