在 Python 中生成具有给定复数根的 Hermite 级数
要生成具有给定复数根的 Hermite 级数,请在 Python Numpy 中使用 hermite.hermfromroots() 方法。该方法返回一个 1-D 系数数组。如果所有根都是实数,则 out 是实数数组;如果某些根是复数,则即使结果中所有系数都是实数,out 也是复数。参数 roots 是包含根的序列。
步骤
首先,导入所需的库 −
from numpy.polynomial import hermite as H
要生成具有给定复数根的 Hermite 级数,请使用 hermite.hermfromroots() 方法 −
j = complex(0,1)
print("Result...\n",H.hermfromroots((-j, j)))获取数据类型 −
print("\nType...\n",H.hermfromroots((-j, j)).dtype)获取形状 −
print("\nShape...\n",H.hermfromroots((-j, j)).shape)实例
from numpy.polynomial import hermite as H
# To generate a Hermite series with given complex roots, use the hermite.hermfromroots() method in Python Numpy.
# The method returns a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real.
# The parameter roots are the sequence containing the roots.
j = complex(0,1)
print("Result...\n",H.hermfromroots((-j, j)))
# Get the datatype
print("\nType...\n",H.hermfromroots((-j, j)).dtype)
# Get the shape
print("\nShape...\n",H.hermfromroots((-j, j)).shape)输出
Result... [1.5 +0.j 0. +0.j 0.25+0.j] Type... complex128 Shape... (3,)
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP