Evaluate a Hermite series at points x with multidimensional coefficient array in Python

To evaluate a Hermite series at points x with a multidimensional coefficient array, use the hermite.hermval() method in NumPy. This function allows you to compute Hermite polynomial values efficiently with complex coefficient structures.

Syntax

numpy.polynomial.hermite.hermval(x, c, tensor=True)

Parameters

The function accepts three parameters:

  • x: Points at which to evaluate the series. Can be a scalar, list, or array
  • c: Coefficient array where c[n] contains coefficients for degree n terms
  • tensor: Boolean flag controlling evaluation behavior (default: True)

Basic Example

Let's start with a simple multidimensional coefficient array ?

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

# Create a multidimensional coefficient array
c = np.array([[1, 2], [3, 4]])

print("Coefficient Array:")
print(c)
print(f"\nShape: {c.shape}")
print(f"Dimensions: {c.ndim}")
Coefficient Array:
[[1 2]
 [3 4]]

Shape: (2, 2)
Dimensions: 2

Evaluating the Hermite Series

Now evaluate the Hermite series at specific points ?

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

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

# Evaluate at points [1, 2]
result = H.hermval([1, 2], c)

print("Hermite series evaluation:")
print(result)
Hermite series evaluation:
[[ 7. 13.]
 [10. 18.]]

Understanding the Tensor Parameter

The tensor parameter controls how coefficients and points interact ?

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

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

# With tensor=True (default)
result_tensor = H.hermval(x, c, tensor=True)
print("With tensor=True:")
print(result_tensor)

# With tensor=False  
result_broadcast = H.hermval(x, c, tensor=False)
print("\nWith tensor=False:")
print(result_broadcast)
With tensor=True:
[[ 7. 13.]
 [10. 18.]]

With tensor=False:
[[ 7. 13.]
 [10. 18.]]

How It Works

For a 2D coefficient array, each column represents a separate polynomial. The Hermite series is computed as:

  • Degree 0 term: c[0] × H?(x) = c[0] × 1
  • Degree 1 term: c[1] × H?(x) = c[1] × 2x
  • Higher degree terms follow Hermite polynomial definitions

Multiple Evaluation Points

You can evaluate at multiple points 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
points = [0, 1, 2, 3]
result = H.hermval(points, c)

print("Evaluation at multiple points:")
print("Points:", points)
print("Results:")
print(result)
Evaluation at multiple points:
Points: [0, 1, 2, 3]
Results:
[[ 1.  2.]
 [ 7. 10.]
 [13. 18.]
 [19. 26.]]

Conclusion

The hermite.hermval() method efficiently evaluates Hermite series with multidimensional coefficients. Use the tensor parameter to control how evaluation points interact with coefficient columns for complex polynomial computations.

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

180 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements