hermite.hermval2d method
In Python, To evaluate a Hermite series at points x with a multidimensional coefficient array, NumPy provides a function called hermite.hermval(), But to evaluate 2D Hermite series, hermite.hermval2d() is used to evaluate a 2D Hermite series at points (x,y). where coefficient_array is the input NumPy array with coefficients and points referred to as x and y. The first parameter can be a list of points. So we have to provide two lists such that each list has an x-point and y-point. The second parameter is a NumPy array of coefficients ordered.
Syntax: hermite.hermval2d(x,y,c)
Parameters:
- x,y: array_like, compatible objects
- c: Array of coefficients.
Return: The values of the two dimensional polynomial at points.
Example 1:
In this example, we are creating a NumPy array with 5 coefficients to evaluate Hermite Series at points [3,4],[1,2]. By using ndim, we are getting a total number of dimensions, and using shape, we are returning the shape of an array.
Python3
# import numpy module import numpy # import hermite from numpy.polynomial import hermite # Create 1d array of 5 elements coefficient_array = numpy.array([ 45 , 67 , 54 , 53 , 15 ]) # Display print (coefficient_array) # display the Dimensions print (coefficient_array.ndim) # display Shape print (coefficient_array.shape) # Evaluate a 2D hermite series at points # (x,y) - [3,4],[1,2] print (hermite.hermval2d([ 3 , 4 ], [ 1 , 2 ], coefficient_array)) |
Output:
[45 67 54 53 15] 1 (5,) [182205. 339447.]
Example 2:
In this example, we are creating a NumPy array with 6 coefficients and evaluating Hermite Series at points [1,4],[1,2]. By using ndim, we are getting a total number of dimensions, and using shape, we are returning the shape of an array.
Python3
# import numpy module import numpy # import hermite from numpy.polynomial import hermite # Create 1d array of 6 elements coefficient_array = numpy.array([ 45 , 67 , 54 , 53 , 67 , 15 ]) # Display print (coefficient_array) # display the Dimensions print (coefficient_array.ndim) # display Shape print (coefficient_array.shape) # Evaluate a 2D hermite series at points # (x,y) - [1,4],[1,2] print (hermite.hermval2d([ 1 , 4 ], [ 1 , 2 ], coefficient_array)) |
Output:
[45 67 54 53 67 15] 1 (6,) [1193457. 2388299.]
Example 3:
In this example, we are creating a 2 D NumPy array with 3 coefficients each and evaluating Hermite Series at points [1,4],[1,2]. By using ndim, we are getting a total number of dimensions, and using shape, we are returning the shape of an array.
Python3
# import numpy module import numpy # import hermite from numpy.polynomial import hermite # Create 2d array of 3 elements each coefficient_array = numpy.array([[ 45 , 67 , 54 ], [ 53 , 67 , 15 ]]) # Display print (coefficient_array) # display the Dimensions print (coefficient_array.ndim) # display Shape print (coefficient_array.shape) # Evaluate a 2D hermite series at points # (x,y) - [1,4],[1,2] print (hermite.hermval2d([ 1 , 4 ], [ 1 , 2 ], coefficient_array)) |
Output:
[[45 67 54] [53 67 15]] 2 (2, 3) [ 721. 5317.]
Evaluate a 2-D Hermite series at points (x,y) in using NumPy Python
In this article, we will Evaluate a 2D Hermite series at points (x,y) in Numpy using python.