在Python中计算Hermite_e级数的根

在Python中计算Hermite_e级数的根

要计算Hermite_e级数的根,可以使用Python Numpy中的hermite.hermroots()方法。该方法返回一个数组,包含级数的根。如果所有根都是实数,则返回结果也是实数,否则返回复数。参数c是一个一维数组,包含了系数。

根的估计值是通过 companion matrix 的特征值计算得到的,远离复平面原点的根可能由于该值的数值不稳定性而产生较大误差。具有大于1重数的根在附近值对于根错误比较不敏感,因此也会产生较大误差。靠近原点的孤立根可以通过几次Newton方法的迭代来改进。

步骤

首先,导入所需的库 –

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

要计算埃尔米特级数的根,可以使用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,)

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程