# NumPy np.hermegrid2d() and np.hermegrid3d() methods in Python

In this tutorial, we are going to learn about hermegrid2d() and hermegrid3d() methods of the NumPy module in Python. These methods help us to evaluate the **probabilists’**** **Hermite series on a given cartesian product. Let’s go through these methods one by one.

## np.hermegrid2d() in Python

This NumPy method evaluates a two dimensional Hermite series with given inputs. If you have no idea about what is a Hermite series.

The syntax for np.hermegrid() method is as follows:

np.hermegrid(x, y, c);

In the above syntax, x and y are array-like objects and c is an array of coefficients for terms of degree that are contained in c. The Hermite series is evaluated at the points of cartesian products of parameters x and y.

The function returns the values of 2-D polynomials obtained at points in the cartesian product of x and y parameters passed in the function hermegrid().

See the given example program for a better understanding.

import numpy as np from numpy.polynomial.hermite_e import hermegrid2d c = np.array([[9, 8, 7, 6], [5, 4, 3, 2]]) hermite = hermegrid2d([3, 2], [0, 1], c) print(hermite)

The output of the above code:

[[ 8. 20.] [ 6. 15.]]

As you can see, we have first created a NumPy array c and then passed it in hermegrid2d() function with other parameters x and y. The output is a two-dimensional Hermite series.

## np.hermegrid3d() in Python

This NumPy method evaluates a three-dimensional Hermite series on cartesian products of given values of x, y, and z. It has the following syntax:

np.hermegrid(x, y, z, c);

Here, x, y, and z are array-like objects and c is an array of coefficients as in np.heremgrid2d().

The function returns the evaluated 3-D Hermite series for the given inputs. See the below code.

import numpy as np from numpy.polynomial.hermite_e import hermegrid3d c = np.array([[9, 8, 7], [6, 5, 4], [3, 2, 1]]) hermite = hermegrid3d([3, 2], [0, 1], [4, 5], c) print(hermite)

Output:

[[ 72. 84.] [306. 360.]]

Thank you.

Also read: Faker Library in Python

## Leave a Reply