hermite_e.hermeval method
To evaluate a Hermite_e series at points x with a multidimensional coefficient array, NumPy provides a function called hermite_e.hermeval(). It takes two parameters x and c. whereas x is a tuple or list and c is an array of coefficients and, it returns a Hermite_e series at the given input points. i.e – If an array has an element like [1,2,3,4,5], then the Hermite_e series will be 1*P_0 + 2*P_1 + 3*P_2 + 4*P_3 + 5*P_4. Below is the syntax of the hermeval method.
Syntax: hermite_e.hermeval(x, c, tensor)
Parameter:
- x: a list or tuple
- c: an array of coefficients ordered
- tensor: boolean, optional
Return: Hermite_e series at points x
Example 1:
In this example, we are creating a coefficient NumPy array with 5 elements and displaying the shape and dimensions. After that, we are evaluating the Hermite_e series at points – [2,4]
Python3
# import the numpy module import numpy # import hermite_se from numpy.polynomial import hermite_e # create array of coefficients with 5 elements coefficients_data = numpy.array([ 1 , 2 , 3 , 4 , 5 ]) # Display the coefficients print (coefficients_data) # get the shape print (f "\nShape of an array: {coefficients_data.shape}" ) # get the dimensions print (f "Dimension: {coefficients_data.ndim}" ) # Evaluate a Hermite_e series at points - [2,4] print ( "\nHermite_e series" , hermite_e.hermeval( [ 2 , 4 ], coefficients_data, tensor = False )) |
Output:
[1 2 3 4 5] Shape of an array: (5,) Dimension: 1 Hermite_e series [ -3. 1077.]
Example 2:
In this example, we are creating a coefficient NumPy array with 5 elements and displaying the shape and dimensions . After that, we are evaluating the Hermite_e series at points – [4,1]
Python3
# import the numpy module import numpy # import hermite_se from numpy.polynomial import hermite_e # create array of coefficients with 5 elements coefficients_data = numpy.array([ 1 , 2 , 3 , 4 , 5 ]) # Display the coefficients print (coefficients_data) # get the shape print (f "\nShape of an array: {coefficients_data.shape}" ) # get the dimensions print (f "Dimension: {coefficients_data.ndim}" ) # Evaluate a Hermite_e series at points - [4,1] print ( "\nHermite_e series" , hermite_e.hermeval( [ 4 , 1 ], coefficients_data, tensor = False )) |
Output:
[1 2 3 4 5] Shape of an array: (5,) Dimension: 1 Hermite_e series [1077. -15.]
Evaluate a Hermite_e series at points x broadcast over the columns of the coefficient in Python
In this article, we will cover how to evaluate a Hermite_e series at points x broadcast over the columns of the coefficient in Python using NumPy.
Example
Input: [1 2 3 4 5] Output: [ -3. 1077.] Explanation: Hermite_e series at input points.