在Python中使用给定的根生成Hermite_e级数
要使用Python Numpy中的hermite_e.hermefromroots()方法生成带有给定根的Hermite_e级数。该方法返回一个一维系数数组。如果所有的根都是实数,则输出是一个实数组;如果有一些根是复数,则输出是复数,即使结果中的所有系数都是实数。参数roots是包含根的序列。
步骤
首先,导入所需的库-
from numpy.polynomial import hermite_e as H
生成给定根的Hermite序列 –
print("Result...\n",H.hermefromroots((-1,0,1)))
获取数据类型 −
print("\nType...\n",H.hermefromroots((-1,0,1)).dtype)
获得形状 −
print("\nShape...\n",H.hermefromroots((-1,0,1)).shape)
示例
from numpy.polynomial import hermite_e as H
# To generate a Hermite_e series with given roots, use the hermite_e.hermefromroots() method in Python Numpy.
print("Result...\n",H.hermefromroots((-1,0,1)))
# Get the datatype
print("\nType...\n",H.hermefromroots((-1,0,1)).dtype)
# Get the shape
print("\nShape...\n",H.hermefromroots((-1,0,1)).shape)
输出
Result...
[0. 2. 0. 1.]
Type...
float64
Shape...
(4,)