In this article, we will be looking at the approach to evaluate a Hermite_e series at an array of points x in Python.
We are using the hermite.hermeval() function in Python Numpy to evaluate a Hermite e series at point x. The first parameter, x, is transformed to an array if it is a list or tuple; otherwise, it is kept unmodified and handled as a scalar. In any scenario, x or its elements must be able to add and multiply with itself as well as with the elements of c. The second parameter ‘C’ is a coefficient array that is sorted in such a way that the coefficients for the terms of degree n are all stored in ‘c[n]’. The remaining indices enumerate distinct polynomials if c is multidimensional. The coefficients in the two-dimensional situation can be thought of as being stored in the columns of c.
Syntax : np.hermeval(x, series)
Return : Return the evaluated hermite series.
Steps to evaluate the Hermite_e series :
Step 1: Import Numpy and hermite_e libraries :
import numpy as np from numpy.polynomial import hermite_e as H
Step 2: Use the hermite.hermeval() function in Python Numpy to evaluate a Hermite_e series at point x as shown below :
x = np.array([[1,2],[3,4]])
print("Result : ",H.hermeval(x,c))
Example 1 :Â
In this example, we are creating a coefficient array of 3 data points and a 2-d array assigned to x and further, we are evaluating a Hermite_e series at points x, using the hermite.hermeval() method in Python.
Python3
# importing necessary libraries import numpy as np from numpy.polynomial import hermite_e as H   # Create an array of coefficients c = np.array([3, 5, 7])   # To evaluate a Hermite_e series at points x, # use the hermite.hermeval() method in Python Numpy x = np.array([[2, 3], [5, 6]]) print("Result : \n", H.hermeval(x, c)) |
Output :Â
Result : [[ 34. 74.] [196. 278.]]
Example 2 :Â
In this example, an array of coefficients is made of 3 points and are evaluating a Hermite_e series at point 1, with the x assigned using the hermite.hermeval() method in Python.
Python3
from numpy.polynomial import hermite_e as H Â Â coef = [3, 5, 7] print("Result 1 : \n",H.hermeval(1, coef)) Â Â x = [[2, 3], [5, 6]] print("Result 2 : \n",H.hermeval(x, coef)) |
Output :
Result 1 : 8.0 Result 2 : [[ 34. 74.] [196. 278.]]
