Generate a Pseudo Vandermonde matrix of the Hermite polynomial in Python

To generate a pseudo Vandermonde matrix of the Hermite polynomial, use the hermite.hermvander2d() method in Python NumPy. This method returns a 2D pseudo-Vandermonde matrix where each row corresponds to a point and each column represents a basis function.

The parameter x, y are arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter deg is a list of maximum degrees of the form [x_deg, y_deg].

Syntax

numpy.polynomial.hermite.hermvander2d(x, y, deg)

Parameters

The function accepts the following parameters:

  • x, y: Arrays of point coordinates with the same shape
  • deg: List of maximum degrees [x_deg, y_deg]

Example

Let's create a complete example to generate a pseudo Vandermonde matrix ?

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

# Create arrays of point coordinates
x = np.array([1, 2])
y = np.array([3, 4])

# Display the arrays
print("Array1...")
print(x)
print("\nArray2...")
print(y)

# Display the datatype
print("\nArray1 datatype:", x.dtype)
print("Array2 datatype:", y.dtype)

# Check the dimensions and shape
print("\nDimensions of Array1:", x.ndim)
print("Dimensions of Array2:", y.ndim)
print("\nShape of Array1:", x.shape)
print("Shape of Array2:", y.shape)

# Generate pseudo Vandermonde matrix
x_deg, y_deg = 2, 3
result = H.hermvander2d(x, y, [x_deg, y_deg])
print("\nPseudo Vandermonde Matrix:")
print(result)
Array1...
[1 2]

Array2...
[3 4]

Array1 datatype: int64
Array2 datatype: int64

Dimensions of Array1: 1
Dimensions of Array2: 1

Shape of Array1: (2,)
Shape of Array2: (2,)

Pseudo Vandermonde Matrix:
[[1.000e+00 6.000e+00 3.400e+01 1.800e+02 2.000e+00 1.200e+01 6.800e+01
  3.600e+02 2.000e+00 1.200e+01 6.800e+01 3.600e+02]
 [1.000e+00 8.000e+00 6.200e+01 4.640e+02 4.000e+00 3.200e+01 2.480e+02
  1.856e+03 1.400e+01 1.120e+02 8.680e+02 6.496e+03]]

Understanding the Output

The resulting matrix has dimensions (2, 12) where:

  • 2 rows correspond to the 2 coordinate points: (1,3) and (2,4)
  • 12 columns represent all combinations of Hermite polynomials up to degrees (2,3)
  • Each element evaluates the corresponding Hermite polynomial basis function at the given point

Matrix Structure

For degrees [x_deg=2, y_deg=3], the columns represent:

  • H?(x)H?(y), H?(x)H?(y), H?(x)H?(y), H?(x)H?(y)
  • H?(x)H?(y), H?(x)H?(y), H?(x)H?(y), H?(x)H?(y)
  • H?(x)H?(y), H?(x)H?(y), H?(x)H?(y), H?(x)H?(y)

Conclusion

The hermvander2d() function generates a pseudo Vandermonde matrix for 2D Hermite polynomial fitting. This matrix is useful for polynomial interpolation and least squares fitting in two dimensions.

Updated on: 2026-03-26T20:37:22+05:30

195 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements