在Python中对具有多维系数的Legendre级数进行特定轴的求导
要对Legendre级数进行求导,在Python中使用polynomial.laguerre.legder()方法。返回沿特定轴对Legendre级数系数c进行m次求导的结果。每次迭代,结果都会乘以scl。第一个参数c是一个Legendre级数系数的数组。如果c是多维的,不同的轴对应不同的变量,每个轴的次数由相应的索引给出。
第二个参数m是要进行的导数次数,必须是非负的。(默认:1)。第三个参数scl是一个标量,每次求导都会乘以scl。最终结果是乘以scl**m。这用于线性变量的变换。(默认:1)。第四个参数axis是要进行导数的轴。(默认:0)。
步骤
首先,导入所需的库−
import numpy as np
from numpy.polynomial import legendre as L
创建一个多维数组的系数 –
c = np.arange(4).reshape(2,2)
显示数组 –
print("Our 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)
要区分Legendre级数,请使用Python中的polynomial.laguerre.legder()方法
print("\nResult...\n",L.legder(c, axis = 1))
示例
import numpy as np
from numpy.polynomial import legendre as L
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)
# Display the array
print("Our 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 differentiate a Legendre series, use the polynomial.laguerre.legder() method in Python
print("\nResult...\n",L.legder(c, axis = 1))
输出
Our Array...
[[0 1]
[2 3]]
Dimensions of our Array...
2
Datatype of our Array object...
int64
Shape of our Array object...
(2, 2)
Result...
[[1.]
[3.]]