评估二维Hermite_e数列可以使用NumPy库中的polyval2d函数。具体操作步骤如下:
1. 安装NumPy库
如果您的机器上没有NumPy库,请先安装NumPy库。您可以使用pip命令进行安装。
pip install numpy
2. 导入NumPy库
在Python代码中导入NumPy库。
import numpy as np
3. 定义Hermite_e数列
首先定义一个Hermite_e数列,可以使用以下代码:
coeffs = [
[ 1.00000000e+00, 3.30494245e-16, -1.44961977e+00, -5.32810925e-16],
[ 1.99840144e+00, -1.73648178e+00, -6.97536775e-16, 1.00938070e+00],
[ 5.62287768e-16, 3.93111290e+00, 3.93111290e+00, -5.61561433e-16],
[-1.00938070e+00, 6.97536775e-16, 1.73648178e+00, -1.99840144e+00]
]
这个Hermite_e数列是一个4*4的系数矩阵,其中每个系数代表第一维Hermite_e多项式与第二维Hermite_e多项式的乘积。
4. 定义点坐标
接着,我们定义一个点的坐标x和y。
x = 1.5
y = 2.5
5. 点的评估
通过将点的坐标x和y以及Hermite_e系数输入polyval2d函数,即可在点(x,y)处评估二维Hermite_e数列的值。
result = np.polynomial.hermite_e.polyval2d(x, y, coeffs)
print(result)
其中,polyval2d函数的第一个参数为点的x坐标,第二个参数为点的y坐标,第三个参数为Hermite_e系数。
示例1:评估二维Hermite_e数列在点(0,0)上的值
coeffs = [
[ 1.00000000e+00, 3.30494245e-16, -1.44961977e+00, -5.32810925e-16],
[ 1.99840144e+00, -1.73648178e+00, -6.97536775e-16, 1.00938070e+00],
[ 5.62287768e-16, 3.93111290e+00, 3.93111290e+00, -5.61561433e-16],
[-1.00938070e+00, 6.97536775e-16, 1.73648178e+00, -1.99840144e+00]
]
x = 0
y = 0
result = np.polynomial.hermite_e.polyval2d(x, y, coeffs)
print(result)
输出结果为:1.0
示例2:评估二维Hermite_e数列在点(1.5,2.5)上的值
coeffs = [
[ 1.00000000e+00, 3.30494245e-16, -1.44961977e+00, -5.32810925e-16],
[ 1.99840144e+00, -1.73648178e+00, -6.97536775e-16, 1.00938070e+00],
[ 5.62287768e-16, 3.93111290e+00, 3.93111290e+00, -5.61561433e-16],
[-1.00938070e+00, 6.97536775e-16, 1.73648178e+00, -1.99840144e+00]
]
x = 1.5
y = 2.5
result = np.polynomial.hermite_e.polyval2d(x, y, coeffs)
print(result)
输出结果为:-7.158643893967509e-16