在 Python 中计算具有给定复根的 Hermite 级数的根
要计算 Hermite 级数的根,可以使用 Python Numpy 中的 hermite.hermroots() 方法。该方法返回级数根的数组。如果所有根都是实数,则输出也是实数,否则为复数。参数 c 是一个 1 维的系数数组。
根的估计值是作为伴随矩阵的特征值获得的,远离复平面原点的根由于此类值的级数数值不稳定而可能存在较大的误差。多重性大于 1 的根也会显示更大的误差,因为该点附近级数的值对根的误差相对不敏感。可以通过牛顿法迭代几次来改进靠近原点的孤立根。
步骤
首先,导入所需的库 -
from numpy.polynomial import hermite as H
要计算 Hermite 级数的根,可以使用 Python Numpy 中的 hermite.hermroots() 方法 -
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,)
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP