在Python中计算具有给定复根的Hermite级数的根

在Python中计算具有给定复根的Hermite级数的根

要计算Hermite级数的根,可以使用Python Numpy中的hermite.hermroots()方法。该方法返回系列的根数组。如果所有根都是实根,则结果也是实数,否则为复数。参数c是一个1-D数组,用于存储系数。

根的估计值是通过伴随矩阵的特征值获得的。远离复平面原点的根可能会由于数值不稳定性而产生较大的误差。具有多重性大于1的根也将显示出较大的误差,因为在这些点附近的系列值对根的误差比较不敏感。靠近原点的孤立根可以通过几次牛顿迭代方法进行改进。

步骤

首先,导入所需的库-

from numpy.polynomial import hermite as H

使用Python Numpy中的hermite.hermroots()方法来计算Hermite级数的根。

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

获取数据类型 –

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

获取形状 –

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

示例

from numpy.polynomial import hermite as H

# To compute the roots of a Hermite 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.
j = complex(0,1)
print("Result...\n",H.hermroots((-j, j)))

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

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

输出

Result...
   [0.5+0.j]

Type...
complex128

Shape...
(1,)

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程