Generate a Vandermonde matrix of the Hermite_e polynomial with float array of points in Python

To generate a Vandermonde matrix of the Hermite_e polynomial with a float array of points, use the numpy.polynomial.hermite_e.hermevander() function. This function returns a pseudo-Vandermonde matrix where each column represents a different degree of the Hermite_e polynomial evaluated at the input points.

The Hermite_e polynomials (also called "physicists' Hermite polynomials") are orthogonal polynomials commonly used in quantum mechanics and probability theory. The Vandermonde matrix is useful for polynomial fitting and interpolation.

Syntax

numpy.polynomial.hermite_e.hermevander(x, deg)

Parameters

x: Array of points. The dtype is converted to float64 or complex128 depending on whether any elements are complex. If x is scalar, it's converted to a 1-D array.

deg: Degree of the resulting matrix. This determines the number of columns in the output matrix.

Return Value

Returns a pseudo-Vandermonde matrix with shape x.shape + (deg + 1,). The last index corresponds to the degree of the Hermite polynomial. The dtype matches the converted input array.

Example

Let's create a Vandermonde matrix of degree 2 for a set of float points ?

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

# Create an array of float points
x = np.array([0, 3.5, -1.4, 2.5])

# Display the array
print("Our Array...")
print(x)

# Check array properties
print("\nDimensions of our Array...")
print(x.ndim)

print("\nDatatype of our Array object...")
print(x.dtype)

print("\nShape of our Array object...")
print(x.shape)

# Generate Vandermonde matrix of degree 2
print("\nVandermonde Matrix (degree 2)...")
result = H.hermevander(x, 2)
print(result)
Our Array...
[ 0.   3.5 -1.4  2.5]

Dimensions of our Array...
1

Datatype of our Array object...
float64

Shape of our Array object...
(4,)

Vandermonde Matrix (degree 2)...
[[ 1.    0.   -1.  ]
 [ 1.    3.5  11.25]
 [ 1.   -1.4   0.96]
 [ 1.    2.5   5.25]]

How It Works

The resulting matrix has 4 rows (one for each input point) and 3 columns (degree + 1). Each column represents:

  • Column 0: H?(x) = 1 (constant term)
  • Column 1: H?(x) = x (linear term)
  • Column 2: H?(x) = x² - 1 (quadratic term)

Higher Degree Example

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

# Create points and generate degree 4 matrix
x = np.array([0, 1, -1])
matrix = H.hermevander(x, 4)

print("Input points:", x)
print("\nVandermonde Matrix (degree 4):")
print(matrix)
Input points: [ 0  1 -1]

Vandermonde Matrix (degree 4):
[[ 1.  0. -1.  0.  3.]
 [ 1.  1.  0. -2.  0.]
 [ 1. -1.  0.  2.  0.]]

Conclusion

The hermevander() function efficiently generates Vandermonde matrices for Hermite_e polynomials, making it useful for polynomial fitting and numerical analysis. Each row corresponds to an input point, and each column represents a different polynomial degree.

---
Updated on: 2026-03-26T21:00:41+05:30

183 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements