在Python中使用给定的复数根生成Hermite_e级数
要使用Python Numpy中的hermite_e.hermefromroots()方法生成具有给定复数根的Hermite_e级数。该方法返回一个一维数组,包含系数。如果所有根都是实数,则out是一个实数组;如果一些根是复数,则out也是复数,即使结果中的所有系数都是实数。参数roots是包含根的序列。
步骤
首先,导入所需的库 –
from numpy.polynomial mport hermite_e as H
生成一个给定复根的Hermite_e级数 −
j = complex(0,1)
print("Result...\n",H.hermefromroots((-j, j)))
获取数据类型 –
print("\nType...\n",H.hermefromroots((-j, j)).dtype)
获取形状 –
print("\nShape...\n",H.hermefromroots((-j, j)).shape)Create an array
示例
from numpy.polynomial import hermite_e as H
j = complex(0,1)
print("Result...\n",H.hermefromroots((-j, j)))
# Get the datatype
print("\nType...\n",H.hermefromroots((-j, j)).dtype)
# Get the shape
print("\nShape...\n",H.hermefromroots((-j, j)).shape)
输出
Result...
[2.+0.j 0.+0.j 1.+0.j]
Type...
complex128
Shape...
(3,)