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

To evaluate a Hermite_e series at points x, use the hermite_e.hermeval() method in Python NumPy. This function is particularly useful when working with multidimensional coefficient arrays.

Parameters

The hermeval() function accepts three parameters:

  • x: The points at which to evaluate the series. Can be a scalar, list, tuple, or ndarray
  • c: Array of coefficients where c[n] contains coefficients for terms of degree n. For multidimensional arrays, additional indices enumerate multiple polynomials
  • tensor: Boolean flag (default True) that controls how coefficients are broadcast with evaluation points

Basic Example

Let's create a multidimensional coefficient array and evaluate the Hermite_e series ?

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

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

# Display the array properties
print("Coefficient Array:")
print(c)
print(f"\nDimensions: {c.ndim}")
print(f"Shape: {c.shape}")
print(f"Datatype: {c.dtype}")

# Evaluate Hermite_e series at points [1, 2]
result = H.hermeval([1, 2], c)
print(f"\nResult:\n{result}")
Coefficient Array:
[[1 2]
 [3 4]]

Dimensions: 2
Shape: (2, 2)
Datatype: int64

Result:
[[ 4.  7.]
 [ 6. 10.]]

Understanding the Result

The result matrix has shape (2, 2) because we evaluated at 2 points with 2 polynomial columns. Each column in the coefficient array represents a separate polynomial, and each row in the result corresponds to an evaluation point.

Different Evaluation Points

You can evaluate at different points to see how the series behaves ?

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

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

# Evaluate at single point
single_point = H.hermeval(0, c)
print(f"At x=0: {single_point}")

# Evaluate at multiple points
multiple_points = H.hermeval([0, 1, 2], c)
print(f"\nAt x=[0,1,2]:\n{multiple_points}")
At x=0: [1. 2.]

At x=[0,1,2]:
[[1. 2.]
 [4. 7.]
 [6. 10.]]

How It Works

For a 2D coefficient array, the Hermite_e series evaluation follows the formula:

P(x) = c[0] + c[1]*H_1(x) + c[2]*H_2(x) + ...

Where H_n(x) are the probabilists' Hermite polynomials. Each column in the coefficient array represents a separate polynomial series.

Conclusion

The hermite_e.hermeval() function efficiently evaluates Hermite_e series with multidimensional coefficients. Use it when you need to evaluate multiple polynomial series simultaneously at various points.

Updated on: 2026-03-26T20:48:44+05:30

196 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements