在 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