Evaluate a Hermite_e series at points x when coefficients are multi-dimensional in Python

To evaluate a Hermite_e series at points x with multi-dimensional coefficients, use the hermite_e.hermeval() method in Python NumPy. This function allows you to evaluate multiple Hermite_e polynomials simultaneously when coefficients are stored in a multi-dimensional array.

Parameters

The hermeval() function takes three main parameters ?

  • x ? Evaluation points. Can be a scalar, list, or array. Must support addition and multiplication operations.
  • c ? Coefficient array where c[n] contains coefficients for degree n terms. For multi-dimensional arrays, additional dimensions represent multiple polynomials.
  • tensor ? Boolean flag (default True). When True, evaluates each column of coefficients for every element of x. When False, broadcasts x over coefficient columns.

Example with Multi-dimensional Coefficients

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

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

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

# Display the coefficient array
print("Coefficient Array:")
print(c)

# Check array properties
print(f"\nDimensions: {c.ndim}")
print(f"Shape: {c.shape}")
print(f"Datatype: {c.dtype}")
Coefficient Array:
[[0 1]
 [2 3]]

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

Evaluating at Multiple Points

Now evaluate the Hermite_e series at points [1, 2] ?

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

c = np.arange(4).reshape(2, 2)

# Evaluate Hermite_e series at points [1, 2]
result = H.hermeval([1, 2], c)
print("Evaluation Result:")
print(result)

# Each column represents a different polynomial
print(f"\nShape of result: {result.shape}")
Evaluation Result:
[[2. 4.]
 [4. 7.]]

Shape of result: (2, 2)

How It Works

The coefficient array c = [[0, 1], [2, 3]] represents two polynomials:

  • Polynomial 1: 0 + 2x (coefficients [0, 2])
  • Polynomial 2: 1 + 3x (coefficients [1, 3])

When evaluated at x = 1: [0 + 2(1), 1 + 3(1)] = [2, 4]

When evaluated at x = 2: [0 + 2(2), 1 + 3(2)] = [4, 7]

Conclusion

The hermite_e.hermeval() method efficiently evaluates multiple Hermite_e polynomials simultaneously using multi-dimensional coefficient arrays. Each column in the coefficient array represents a separate polynomial, making it useful for batch processing multiple series evaluations.

Updated on: 2026-03-26T21:04:08+05:30

218 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements