用NumPy将多项式转换为Hermite数列

用NumPy将多项式转换为Hermite数列

在这篇文章中,我们将讨论如何使用NumPy将多项式转换为Hermite系列。

示例:

多项式: [4 2 3 6] 。

转换后的等效赫米特级数的系数: [5.5 5.5 0.75 0.75] 。

为了将多项式转换为Hermite数列,我们需要使用numpy方法hermite.poly2herm()。 我们可以通过使用np.poly2herm()方法从多项式中获得赫米特级数的系数。

语法 : np.poly2herm(polynomial)

返回 : 返回 hermite 系列的系数。

例1:转换为物理学家的Hermite系列

# Import required libraries
import numpy as np
from numpy.polynomial import hermite
 
# Now define a polynomial you want to convert
pol = np.array([4, 2, 3, 6])
 
# Now convert the polynomial to a Hermite
# Series (Physicist's Hermite Series)
converted = hermite.poly2herm(pol)
 
# Now print the results
print("Coefficients of the defined polynomial:", pol)
print("Converting by Physicist's Hermite series..")
print("Coefficients of the converted\
equivalent Hermite series :", converted)

输出:

Coefficients of the defined polynomial: [4 2 3 6]

Converting by Physicist’s Hermite series..

Coefficients of the converted equivalent Hermite series : [5.5 5.5 0.75 0.75]

例2:转换为概率论者的赫米特数列

# Import required libraries
import numpy as np
from numpy.polynomial import hermite_e
 
# Now define a polynomial you want to convert
pol = np.array([4, 2, 3, 6])
 
# Now convert the polynomial to
# a Hermite Series (Probabilist's Hermite Series)
converted = hermite_e.poly2herme(pol)
 
# Now print the results
print("Coefficients of the defined polynomial:", pol)
print("Converting by Probabilist's Hermite series..")
print("Coefficients of the converted \
equivalent Hermite series :", converted)

输出:

Coefficients of the defined polynomial: [4 2 3 6]

Converting by Probabilist’s Hermite series..

Coefficients of the converted equivalent Hermite series : [ 7. 20. 3. 6.]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Numpy 多项式