用 Python 计算勒让德级数的根
要计算勒让德级数的根,请在 Python 中使用 polynomial.legendre.legroots() 方法。该方法返回级数根的数组。如果所有根均为实数,则输出也将为实数,否则为复数。参数 c 是一个 1-D 系数数组。
步骤
首先,导入所需的库 −
from numpy.polynomial import legendre as L
要计算勒让德级数的根,请在 Python 中使用 polynomial.legendre.legroots() 方法 −
print("Result...\n",L.legroots((0, 1, 2)))获取数据类型 −
print("\nType...\n",L.legroots((0, 1, 2)).dtype)获取形状 −
print("\nShape...\n",L.legroots((0, 1, 2)).shape)
示例
from numpy.polynomial import legendre as L
# To compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python
print("Result...\n",L.legroots((0, 1, 2)))
# Get the datatype
print("\nType...\n",L.legroots((0, 1, 2)).dtype)
# Get the shape
print("\nShape...\n",L.legroots((0, 1, 2)).shape)输出
Result... [-0.76759188 0.43425855] Type... float64 Shape... (2,)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP