用Python生成给定复数根的拉盖尔级数
pythonnumpyserver side programmingprogramming更新于 2024/6/5 1:48:17
要生成给定根的拉盖尔级数,请使用Python Numpy中的laguerre.lagfromroots()方法。该方法是一个一维系数数组。如果所有根都是实数,则out是实数数组,如果某些根是复数,则即使结果中的所有系数都是实数,out也是复数。参数roots是包含根的序列。
步骤
首先,导入所需的库 −
from numpy.polynomial import laguerre as L
要生成给定根的拉盖尔级数,请使用laguerre.lagfromroots()方法−
j = complex(0,1)
print("结果...\n",L.lagfromroots((-j, j)))
获取数据类型 −
print("\n类型...\n",L.lagfromroots((-j, j)).dtype)
获取形状 −
print("\n形状...\n",L.lagfromroots((-j, j)).shape)
示例
from numpy.polynomial import laguerre as L
# 要生成具有给定根的拉盖尔级数,请使用 Python Numpy 中的 laguerre.lagfromroots() 方法。
# 该方法是一个一维系数数组。如果所有根都是实数,则 out 是实数数组;如果某些根是复数,则即使结果中的所有系数都是实数,out 也是复数。
# 参数 roots 是包含根的序列。
j = complex(0,1)
print("结果...\n",L.lagfromroots((-j, j)))
# 获取数据类型
print("\n类型...\n",L.lagfromroots((-j, j)).dtype)
# 获取形状
print("\n形状...\n",L.lagfromroots((-j, j)).shape)
输出
结果... [ 3.+0.j -4.+0.j 2.-0.j] 类型... complex128 形状... (3,)
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

