Open In App

Convert a Polynomial to Hermite Series Using NumPy

In this article, we will discuss how to convert a Polynomial to Hermite series using NumPy.

Example:



Polynomial: [4 2 3 6]

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



To convert a polynomial to Hermite series we need to use numpy methods hermite.poly2herm(). We can get the hermite series coefficient from polynomial by using np.poly2herm() method.

Syntax : np.poly2herm(polynomial)
Return : Return the coefficient of hermite series.

Example 1: Convert to Physicist’s Hermite Series




# 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)

 Output:

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]

Example 2: Convert to Probabilist’s Hermite Series




# 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)

Output: 

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.]


Article Tags :