Open In App

Evaluate a 2-D Hermite_e series at points (x,y) with 3D array of coefficient using NumPy in Python

Last Updated : 03 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to evaluate a 2-D Hermite_e series at points (x,y) with a 3D array of coefficients using NumPy in Python.

np.polynomial.hermite_e.hermeval2d method

The np.polynomial.hermite_e.hermeval2d from the NumPy library is used to Evaluate a 2-D Hermite_e series at points(x,y) in Python. If the parameters x and y are tuples or lists, they are converted to arrays otherwise they are treated as scalars and must have the same shape after conversion. In either case, x and y or their elements must support multiplication and addition with themselves as well as with the elements of c. If c is a one-dimensional array, a one is implicitly appended to its shape to make it two-dimensional. The final shape will be c.shape[2:] + x.shape.

Syntax: np.polynomial.hermite_e.hermeval2d(x, y, c)

Parameters :

  • x , y: array like compatible objects.
  • c: array like object.

Returns : The values of the two-dimensional polynomial at coordinates formed by corresponding pairs of x and y values.

Example 1:

The NumPy package is imported. An array is created which represents a 3D array of coefficients of the Hermite series. np.polynomial.hermite_e.hermeval2d(x, y, c) is used to evaluate a 2-D Hermite series, in the below example, arrays are given for x and y parameters which represent multiple points. The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. 

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite_e as mit
  
# array of coefficients
array = np.array([[[5,6],[7,8],[9,10]]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# evaluating a 2-d hermite series at point(x,y) 
# with 3D coeffiecients
print(mit.hermeval2d([1,1],[2,2],array))


Output:

[[[ 5  6]
  [ 7  8]
  [ 9 10]]]
Shape of the array is :  (1, 3, 2)
The dimension of the array is :  3
[[46. 46.]
 [52. 52.]]

Example 2:

The NumPy package is imported. An array is created using np.arange(12).reshape(2, 2, 3) which represents a 3D array of coefficients of the Hermite series. np.polynomial.hermite_e.hermeval2d(x, y, c) is used to evaluate a 2-D Hermite series, The shape, datatype, and dimension of the array are found by using the .shape, .dtype, and .ndim attributes. 

Python3




# import packages
import numpy as np
from numpy.polynomial import hermite_e as mit
  
# array of coefficients
array = np.arange(12).reshape(2, 2, 3)
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# evaluating a 2-d hermite series at point(x,y)
# with 3D coeffiecients
print(mit.hermeval2d([1,1],[2,2],array))


Output:

[[[ 0  1  2]
  [ 3  4  5]]

 [[ 6  7  8]
  [ 9 10 11]]]
Shape of the array is :  (2, 2, 3)
The dimension of the array is :  3
[[30. 30.]
 [36. 36.]
 [42. 42.]]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads