在Python中计算具有给定复根的Laguerre级数的根

在Python中计算具有给定复根的Laguerre级数的根

要计算Laguerre级数的根,可以使用Python Numpy中的laguerre.lagroots()方法。该方法返回一个数组,包含该级数的根。如果所有根都是实数,则返回的结果也是实数;否则为复数。

根的估计值是作为伴随矩阵的特征值获得的。远离复平面原点的根可能因为该数值对于这样的值的级数的数值不稳定性而产生较大的误差。具有大于1的重复根在附近的值对于根误差不敏感,因此也会产生较大的误差。靠近原点的孤立根可以通过几次牛顿迭代法来改善。参数c是一个一维数组,包含系数。

步骤

首先,导入所需的库 –

from numpy.polynomial import laguerre as L

要计算拉盖尔级数的根,可以使用Python Numpy中的laguerre.lagroots()方法−

j = complex(0,1)
print("Result...\n",L.lagroots([-j, j]))

获取数据类型:-

print("\nType...\n",L.lagroots([-j, j]).dtype)

获得形状 −

print("\nShape...\n",L.lagroots([-j, j]).shape)

示例

from numpy.polynomial import laguerre as L

# To Compute the roots of a Laguerre series, use the laguerre.lagroots() 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..

j = complex(0,1)
print("Result...\n",L.lagroots([-j, j]))

# Get the datatype
print("\nType...\n",L.lagroots([-j, j]).dtype)

# Get the shape
print("\nShape...\n",L.lagroots([-j, j]).shape)

输出

Result...
   [0.+0.j]

Type...
complex128

Shape...
(1,)

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程