在Python中评估三维厄尔米特级数在点(x,y,z)处的值
要评估三维厄尔米特级数在点(x, y, z)处的值,使用Python的Numpy库中的hermite.hermval3d()方法。该方法返回由x、y和z对应值组成的点上的多维多项式的值。第一个参数是x、y、z。在点(x, y, z)处计算了三维级数,其中x、y和z必须具有相同的形状。如果x、y或z中的任何一个是列表或元组,则首先将其转换为ndarray,否则将保持不变,如果不是ndarray,则将其视为标量。
第二个参数C是一个按照顺序排列的系数数组,使得多重度为i、j、k的项的系数包含在c[i,j,k]中。如果c的维度大于3,则其余索引将列举多组系数。
步骤
首先,导入所需的库 –
import numpy as np
from numpy.polynomial import hermite as H
将下面的英文翻译成中文,不解释,保留HTML格式:
创建一个系数的3D数组 −
c = np.arange(24).reshape(2,2,6)
展示数组 –
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)
使用Python中的Numpy库的hermite.hermval3d()方法来评估三维Hermite级数在点(x,y,z)处的值。该方法返回多维多项式在由x,y和z的对应值组成的点上的值。
print("\nResult...\n",H.hermval3d([1,2],[1,2],[1,2],c))
示例
import numpy as np
from numpy.polynomial import hermite as H
# Create a 3d array of coefficients
c = np.arange(24).reshape(2,2,6)
# 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 evaluate a 3D Hermite series at points (x, y, z), use the hermite.hermval3d() method in Python Numpy
print("\nResult...\n",H.hermval3d([1,2],[1,2],[1,2],c))
输出
Our Array...
[[[ 0 1 2 3 4 5]
[ 6 7 8 9 10 11]]
[[12 13 14 15 16 17]
[18 19 20 21 22 23]]]
Dimensions of our Array...
3
Datatype of our Array object...
int64
Shape of our Array object...
(2, 2, 6)
Result...
[-4050. 52240.]