Evaluate a Hermite series at array of points x in Python

To evaluate a Hermite series at points x, use the hermite.hermval() method in Python NumPy. This function allows you to compute the value of a Hermite polynomial at specified points using an array of coefficients.

Syntax

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

Parameters

The function accepts three parameters ?

  • x ? Array of points where the Hermite series will be evaluated. If x is a list or tuple, it is converted to an ndarray
  • c ? Array of coefficients ordered so that coefficients for terms of degree n are contained in c[n]
  • tensor ? If True (default), evaluates every column of coefficients for every element of x. If False, broadcasts x over columns of c

Example

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

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

# Create an array of coefficients
c = np.array([1, 2, 3])

# Display the coefficient array
print("Coefficients:", c)
print("Dimensions:", c.ndim)
print("Shape:", c.shape)

# Evaluate at a 2D array of points
x = np.array([[1, 2], [3, 4]])
print("\nPoints x:")
print(x)

# Evaluate the Hermite series
result = H.hermval(x, c)
print("\nHermite series evaluation:")
print(result)
Coefficients: [1 2 3]
Dimensions: 1
Shape: (3,)

Points x:
[[1 2]
 [3 4]]

Hermite series evaluation:
[[ 11.  51.]
 [115. 203.]]

How It Works

The Hermite series is evaluated using the formula: c[0] + c[1]*H?(x) + c[2]*H?(x) + ..., where H?(x) are the Hermite polynomials. For our example with coefficients [1, 2, 3], the series becomes: 1 + 2*H?(x) + 3*H?(x).

Using Different Point Arrays

You can evaluate the series at single points or 1D arrays as well ?

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

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

# Evaluate at a single point
single_point = H.hermval(2, c)
print("At x=2:", single_point)

# Evaluate at a 1D array
x_array = np.array([0, 1, 2])
result_1d = H.hermval(x_array, c)
print("At points [0, 1, 2]:", result_1d)
At x=2: 51.0
At points [0, 1, 2]: [ 1. 11. 51.]

Conclusion

The hermite.hermval() function efficiently evaluates Hermite series at specified points using coefficient arrays. It supports both scalar and array inputs, making it versatile for mathematical computations involving Hermite polynomials.

Updated on: 2026-03-26T19:46:49+05:30

196 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements