Evaluate a Hermite series at list of points x in Python

To evaluate a Hermite series at specific points, use NumPy's hermite.hermval() method. This function computes the value of a Hermite polynomial series at given x-coordinates using coefficient arrays.

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: Array of coefficients where c[n] contains coefficients for degree n terms.
  • tensor: Boolean flag controlling evaluation behavior (default: True).

Basic Example

Let's evaluate a Hermite series with coefficients [1, 2, 3] at points [5, 10, 15] ?

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

# Create coefficient array
c = np.array([1, 2, 3])
print("Coefficients:", c)

# Define evaluation points
x = [5, 10, 15]
print("Evaluation points:", x)

# Evaluate Hermite series
result = H.hermval(x, c)
print("Result:", result)
Coefficients: [1 2 3]
Evaluation points: [5, 10, 15]
Result: [ 315. 1235. 2755.]

How It Works

The Hermite series is calculated as: c[0] + c[1]*H?(x) + c[2]*H?(x) + ... where H?, H? are Hermite polynomials of increasing degree.

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

# Simple coefficient array [a, b, c]
# Represents: a + b*H?(x) + c*H?(x)
c = np.array([1, 0, 2])  # 1 + 0*H?(x) + 2*H?(x)

# Evaluate at single point
x = 2
result = H.hermval(x, c)
print(f"At x = {x}: {result}")

# Evaluate at multiple points
x_points = [1, 2, 3]
results = H.hermval(x_points, c)
print(f"At x = {x_points}: {results}")
At x = 2: 31.0
At x = [1, 2, 3]: [ 7. 31. 73.]

Multidimensional Coefficients

When using 2D coefficient arrays, each column represents a different polynomial series ?

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

# 2D coefficient array - 2 polynomials
c = np.array([[1, 2],   # Coefficients for degree 0
              [3, 4],   # Coefficients for degree 1  
              [5, 6]])  # Coefficients for degree 2

print("Coefficient matrix:")
print(c)

x = [1, 2]
result = H.hermval(x, c)
print("Result shape:", result.shape)
print("Results:")
print(result)
Coefficient matrix:
[[1 2]
 [3 4]
 [5 6]]
Result shape: (2, 2)
Results:
[[21. 28.]
 [63. 84.]]

Comparison with Regular Polynomials

Feature Hermite Series Power Series
Basis Functions Hermite polynomials Powers of x
NumPy Function hermite.hermval() polynomial.polyval()
Application Physics, quantum mechanics General approximation

Conclusion

Use hermite.hermval() to evaluate Hermite polynomial series at specified points. This function is particularly useful in physics and engineering applications where Hermite polynomials provide natural basis functions.

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

252 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements