用 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