在Python中对 Hermite_e 级数进行幂运算
要对 Hermite_e 级数进行幂运算,在 Python 的 Numpy 中使用 polynomial.hermite.hermepow() 方法。该方法返回幂的 Hermite_e 级数。返回 Hermite_e 级数 c 的 pow 次幂。参数 c 是按低到高排序的系数序列,即 [1,2,3]
表示级数 P_0 + 2*P_1 + 3*P_2
。参数 c 是按低到高排序的 Hermite_e 级数系数的一维数组。
参数 pow 是级数将被提升到的幂。参数 maxpower 是允许的最大幂。这主要是为了限制级数的增长,以防止其变得无法处理。默认值为16。
步骤
首先,导入所需的库 −
import numpy as np
from numpy.polynomial import hermite_e as H
创建Hermite_e系数的1-D数组 –
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)
要将Hermite_e级数提升到某个幂次,可以在Python的polynomial.hermite.hermepow()方法中使用
Numpy –
print("\nResult....\n",H.hermepow(c, 3))
示例
import numpy as np
from numpy.polynomial import hermite_e as H
# Create 1-D arrays of Hermite_e 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 Hermite_e series to a power, use the polynomial.hermite.hermepow() method in Python Numpy
# The method returns Hermite_e series of power.
print("\nResult....\n",H.hermepow(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....
[ 355. 642. 1119. 476. 387. 54. 27.]