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

To evaluate a 3D Hermite series at points (x, y, z), use the hermite.hermval3d() method in NumPy. The method returns the values of the multidimensional polynomial on points formed with triples of corresponding values from x, y, and z.

The first parameter consists of x, y, z coordinates. The three dimensional series is evaluated at the points (x, y, z), where x, y, and z must have the same shape. If any of x, y, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar.

The second parameter, C, is an array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in c[i,j,k]. If c has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients.

Syntax

hermite.hermval3d(x, y, z, c)

Parameters

  • x, y, z ? Three dimensional coordinates where the series is evaluated
  • c ? Array of coefficients ordered so that coefficient of term of multi-degree i,j,k is in c[i,j,k]

Example

Let's create a 2D array of coefficients and evaluate a 3D Hermite series ?

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

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

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

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

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

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

# Evaluate 3D Hermite series at points (x, y, z)
print("\nResult...\n", H.hermval3d([1,2], [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...
 [138. 258.]

Understanding the Calculation

The Hermite polynomial evaluation uses the coefficient array where c[i,j,k] represents the coefficient for terms with powers i, j, k in x, y, z respectively. For our 2D coefficient array, it's extended to 3D evaluation ?

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

# Different coefficient array
c = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])

print("3D Coefficient Array:\n", c)
print("Shape:", c.shape)

# Evaluate at single point
result_single = H.hermval3d(1, 1, 1, c)
print("\nResult at point (1,1,1):", result_single)

# Evaluate at multiple points
result_multiple = H.hermval3d([0, 1], [0, 1], [0, 1], c)
print("Result at multiple points:", result_multiple)
3D Coefficient Array:
 [[[1 2]
  [3 4]]

 [[5 6]
  [7 8]]]
Shape: (2, 2, 2)

Result at point (1,1,1): 36.0

Result at multiple points: [ 1. 36.]

Conclusion

The hermite.hermval3d() method efficiently evaluates 3D Hermite series using coefficient arrays. It supports both single point and vectorized multi-point evaluation, making it useful for polynomial approximations in three-dimensional space.

Updated on: 2026-03-26T20:19:21+05:30

175 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements