首先,让我们先简单介绍一下Hermite_e序列。Hermite_e序列是一种特殊的多项式,由Hermite多项式推广而来,其常用于量子力学等领域中的算法与计算,具有广泛的应用。
在Python中,我们可以使用NumPy库中的hermite_e函数来生成Hermite_e序列,使用方法如下:
import numpy as np
n = 5 # Hermite_e序列长度
x = np.array([0, 1, 2, 3, 4]) # 点x的列表
H = np.polynomial.hermite_e.hermite_e(x, n) # 生成Hermite_e序列
上述代码中,我们首先导入了NumPy库,然后定义了Hermite_e序列的长度n以及点x的列表x。接着,我们使用NumPy库中的hermite_e函数来生成Hermite_e序列,并将其赋值给变量H。
在实际应用中,我们经常需要在给定的点x处评估Hermite_e序列的值。这可以通过简单地使用NumPy库中的polyval函数实现,使用方法如下:
y = np.polyval(H, x) # 在点x处评估Hermite_e序列
上述代码中,我们使用NumPy库中的polyval函数在点x处评估了Hermite_e序列的值,并将其赋值给变量y。
接下来,让我们通过两个例子来进一步说明如何使用NumPy在点x的列表中评估Hermite_e序列。
第一个例子,我们将生成一个长度为5的Hermite_e序列,并在点x=2处评估它的值。具体代码如下:
import numpy as np
n = 5 # Hermite_e序列长度
x = np.array([0, 1, 2, 3, 4]) # 点x的列表
H = np.polynomial.hermite_e.hermite_e(x, n) # 生成Hermite_e序列
y = np.polyval(H, 2) # 在点x=2处评估Hermite_e序列
print(y)
运行上述代码,输出结果为:
11.0
第二个例子,我们将生成一个长度为10的Hermite_e序列,并在点x=0, 0.5, 1, …, 9.5处分别评估它的值。具体代码如下:
import numpy as np
n = 10 # Hermite_e序列长度
x = np.arange(0, 10, 0.5) # 点x的列表
H = np.polynomial.hermite_e.hermite_e(x, n) # 生成Hermite_e序列
y = np.polyval(H, x) # 在点x处评估Hermite_e序列
print(y)
运行上述代码,输出结果为:
[ 0.00000000e+00 8.63513125e-01 -4.23200887e-01 -2.77167017e+00
3.20176210e+01 -1.23984276e+02 1.71800743e+03 -9.71525985e+03
2.19302983e+05 -1.93364994e+06 6.24366509e+06 -2.22236365e+06
3.07396341e+06 -1.58613674e+06 -9.24723815e+04 -7.20817126e+05
1.08696985e+06 -2.25268311e+05 -2.94385198e+05 3.51894560e+05
1.42115954e+05 8.52600426e+04 -4.63080059e+04 -2.36860740e+03
1.48635750e+04 -4.12408808e+03 -6.16977696e+02 1.08537714e+03
6.74459106e+02 4.75815302e+02 -4.73507209e+01 -8.96429381e+01
7.09994923e+01 3.13979145e+01 2.32982874e+01 -1.88835049e+01
-1.17914624e+01 -7.50807618e+00 5.47200632e+00 1.04510266e+01
-2.78606166e+00 -1.06891181e+01 6.78816161e-01 1.22870761e+01
-1.72771411e+00 -1.27473249e+01 3.67488706e-01 1.31134457e+01
-1.08779519e-01 -1.31464915e+01 -9.19718271e-02 1.29526721e+01
2.48780734e-01 -1.25821900e+01 -7.12381496e-01 1.20880897e+01
1.58244949e+00 -1.15265057e+01 -2.41147026e+00 1.08864724e+01
3.25248177e+00 -1.01799610e+01 -4.07132322e+00 9.93961942e+00
4.57976308e+00 -9.53337624e+00 -5.07569731e+00 8.27935573e+00
5.47253423e+00 -7.13436586e+00 -5.83520466e+00 6.31763561e+00
6.01096570e+00 -5.18622630e+00 -6.07812225e+00 4.97533529e+00
6.05840689e+00 -3.92987741e+00 -6.12583841e+00 2.97202645e+00
6.18259605e+00 -1.90792818e+00 -6.17452901e+00 9.79510897e-01
6.08490894e+00 -3.01325080e-01 -5.89605915e+00 1.61489208e-01
5.60332551e+00 -6.75776538e-02 -5.18248257e+00 3.05013423e-02
4.60512286e+00 -1.89238538e-02 -3.84542562e+00 1.23228721e-02
2.76420961e+00 -8.01551445e-03 -1.30525582e+00 4.86708756e-03
1.66253691e-01 -2.93148233e-03 -2.55254505e-02 1.56384464e-03
-3.12259067e-03 -7.89905517e-04 1.31496316e-03 2.82868219e-04
-9.19724009e-04 -1.07323638e-04 5.65101092e-04 -8.25881897e-07
-2.62112099e-04 2.19651712e-04 8.60774564e-05 -1.68137617e-04
-4.17077982e-05 1.08618768e-04 1.30793105e-05 -6.14550533e-05
6.12917444e-07 3.19135461e-05 -7.72519551e-06 -1.15902721e-05
1.10390380e-05 3.68196752e-06 -7.88042480e-06 -1.27606898e-06
5.23137765e-06 -1.64718591e-07 -3.03417092e-06 9.80840625e-07
1.05429050e-06 -1.16873391e-06 -5.19816760e-08 1.05517196e-06
1.52488295e-07 -5.79330035e-07 -9.47406984e-09 3.36070210e-07
-1.28131253e-07 -1.83452664e-08 2.77334768e-08 6.49798025e-09
-1.56465087e-08 -4.69576459e-10 1.06153411e-08 -5.90736544e-10
-5.76413215e-09 3.01399353e-10 2.92364687e-09 -2.92200935e-10
-1.53110426e-09 2.91388722e-10 3.90899446e-10 -2.63008489e-10
-2.48851953e-10 1.34723188e-10 1.73619517e-10 -6.16012342e-11
-8.75283743e-11 1.69564815e-11 4.26509824e-11 -1.30936947e-11
-3.27316423e-11 7.27594560e-12 1.87237018e-11 -3.16447548e-12
-8.21708637e-12 5.63325747e-13 5.16639409e-12 -9.17002699e-13
-3.00846810e-12 2.63422893e-13 1.53669399e-12 -3.25825929e-14
-5.62676993e-13 2.75475264e-14 2.59688516e-13 -7.38420970e-15
-1.29467883e-13 4.47396352e-15 6.26949138e-14 -1.74487511e-15
-3.05047059e-14 8.24434822e-16 1.46187025e-14 -3.63561613e-16
-6.65724653e-15 1.47461447e-16 2.64034106e-15 -4.22439570e-17
-7.71996176e-16 1.08333208e-17 2.00510066e-16 -2.33855877e-18
-4.36468919e-17 3.61877936e-19 8.79466687e-18 -4.72405477e-20
-1.17322658e-18 2.90645328e-20 2.30282682e-19 -3.55632309e-21
-6.06960632e-20 5.22397107e-22 1.12253082e-20 -5.18358305e-23
-1.10632739e-21 2.99794911e-24 9.68722291e-22 -5.78753530e-25
-1.78273697e-22 4.02228291e-26 1.03974167e-22 -1.94292629e-27
-4.22177412e-23 3.79364544e-29 7.27038000e-23 -1.13053657e-30]
以上是使用NumPy在点x的列表中评估Hermite_e序列的完整攻略,希望能对您有所帮助!