在 Python 中將勒讓德級數提升到冪
要將勒讓德級數提升到冪,請在 Python Numpy 中使用 polynomial.legendre.legpow() 方法。該方法返回勒讓德級數 c 提升到 pow 次冪。引數 c 是一個從低到高排序的係數序列。即,[1,2,3] 是級數 P_0 + 2*P_1 + 3*P_2。返回勒讓德級數 c 提升到 pow 次冪。引數 c 是一個從低到高排序的係數序列。即,[1,2,3] 是級數 P_0 + 2*P_1 + 3*P_2。
引數 c 是一個一維陣列,包含從低到高排序的勒讓德級數係數。引數 pow 是將級數提升到的冪。引數 maxpower 是允許的最大冪。這主要是為了限制級數增長到無法管理的大小。預設值為 16。
步驟
首先,匯入所需的庫 -
import numpy as np from numpy.polynomial import laguerre as L
建立拉蓋爾級數係數的一維陣列 -
c = np.array([1,2,3])
顯示係數陣列 -
print("Our coefficient Array...\n",c)檢查維度 -
print("\nDimensions of our Array...\n",c.ndim)獲取資料型別 -
print("\nDatatype of our Array object...\n",c.dtype)獲取形狀 -
print("\nShape of our Array object...\n",c.shape)要將勒讓德級數提升到冪,請在 Python Numpy 中使用 polynomial.legendre.legpow() 方法 -
print("\nResult....\n",L.legpow(c, 3))示例
import numpy as np
from numpy.polynomial import legendre as L
# Create 1-D arrays of Laguerre series coefficients
c = np.array([1,2,3])
# Display the coefficient array
print("Our coefficient Array...\n",c)
# Check the Dimensions
print("\nDimensions of our Array...\n",c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n",c.dtype)
# Get the Shape
print("\nShape of our Array object...\n",c.shape)
# To raise a Legendre series to a power, use the polynomial.legendre.legpow() method in Python Numpy
# The method returns the Legendre series c raised to the power pow. The argument c is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series P_0 + 2*P_1 + 3*P_2.
print("\nResult....\n",L.legpow(c, 3))輸出
Our coefficient Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result.... [16.74285714 42.17142857 55.14285714 46.4 33.8025974 15.42857143 6.31168831]
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP