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