Evaluate a 2-D Hermite series at points (x,y) in Python

To evaluate a 2D Hermite series at points (x, y), use the hermite.hermval2d() method in NumPy. The method returns the values of the two-dimensional polynomial at points formed with pairs of corresponding values from x and y.

Syntax

numpy.polynomial.hermite.hermval2d(x, y, c)

Parameters

The function accepts three parameters ?

  • x, y − The two-dimensional series is evaluated at points (x, y), where x and y must have the same shape. If x or y is a list or tuple, it is first converted to an ndarray.
  • c − Array of coefficients ordered so that the coefficient of the term of multi-degree i,j is contained in c[i,j]. If c has dimension greater than two, the remaining indices enumerate multiple sets of coefficients.

Example

Let's create a coefficient array and evaluate the 2D Hermite series at specific points ?

import numpy as np
from numpy.polynomial import hermite as H

# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2,2)

# Display the array
print("Our Array...")
print(c)

# Check the Dimensions
print("\nDimensions of our Array...")
print(c.ndim)

# Get the Datatype
print("\nDatatype of our Array object...")
print(c.dtype)

# Get the Shape
print("\nShape of our Array object...")
print(c.shape)

# Evaluate 2D Hermite series at points (x, y)
print("\nResult...")
print(H.hermval2d([1,2],[1,2],c))
Our Array...
[[0 1]
 [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

Shape of our Array object...
(2, 2)

Result...
[18. 60.]

How It Works

The coefficient matrix represents a 2D polynomial where c[i,j] is the coefficient for the term of degree i in x and degree j in y. The evaluation computes the polynomial value at each (x,y) coordinate pair.

Multiple Points Example

You can evaluate at multiple coordinate pairs simultaneously ?

import numpy as np
from numpy.polynomial import hermite as H

# Coefficient array
c = np.array([[1, 2], [3, 4]])

# Evaluate at multiple points
x_points = [0, 1, 2]
y_points = [0, 1, 2]

result = H.hermval2d(x_points, y_points, c)
print("Evaluation at multiple points:")
print(result)
Evaluation at multiple points:
[ 1. 10. 37.]

Conclusion

The hermval2d() function efficiently evaluates 2D Hermite series at given coordinate points. It accepts coefficient arrays and coordinate pairs, returning polynomial values at each (x,y) location.

Updated on: 2026-03-26T19:59:36+05:30

195 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements