Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Generate a Vandermonde matrix of the Hermite_e polynomial with complex array of points in Python
To generate a Vandermonde matrix of the Hermite_e polynomial, use the hermite_e.hermvander() function in Python NumPy. The method returns the pseudo-Vandermonde matrix where each row corresponds to a point in the input array, and each column corresponds to a polynomial degree.
The shape of the returned matrix is x.shape + (deg + 1,), where the last index represents the degree of the corresponding Hermite polynomial. The dtype will be the same as the converted input array.
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 is converted to a 1-D array.
deg: The degree of the resulting matrix, determining the number of polynomial terms.
Syntax
numpy.polynomial.hermite_e.hermvander(x, deg)
Example
Let's create a Vandermonde matrix using complex array points ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create a complex array
x = np.array([-2.+2.j, -1.+2.j, 0.+2.j, 1.+2.j, 2.+2.j])
# Display the array
print("Our Array...")
print(x)
# Check the dimensions
print("\nDimensions of our Array...")
print(x.ndim)
# Get the datatype
print("\nDatatype of our Array object...")
print(x.dtype)
# Get the shape
print("\nShape of our Array object...")
print(x.shape)
# Generate Vandermonde matrix of Hermite_e polynomial with degree 2
print("\nVandermonde Matrix (degree 2)...")
result = H.hermvander(x, 2)
print(result)
Our Array... [-2.+2.j -1.+2.j 0.+2.j 1.+2.j 2.+2.j] Dimensions of our Array... 1 Datatype of our Array object... complex128 Shape of our Array object... (5,) Vandermonde Matrix (degree 2)... [[ 1.+0.j -2.+2.j -1.-8.j] [ 1.+0.j -1.+2.j -4.-4.j] [ 1.+0.j 0.+2.j -5.+0.j] [ 1.+0.j 1.+2.j -4.+4.j] [ 1.+0.j 2.+2.j -1.+8.j]]
How It Works
The Vandermonde matrix contains evaluations of Hermite_e polynomials of different degrees at each point:
- Column 0: H_0(x) = 1 (constant polynomial)
- Column 1: H_1(x) = x (linear polynomial)
- Column 2: H_2(x) = x² - 1 (quadratic polynomial)
Each row corresponds to evaluating these polynomials at one complex point from the input array.
Conclusion
Use hermite_e.hermvander() to generate Vandermonde matrices for Hermite_e polynomials with complex arrays. The function efficiently evaluates multiple polynomial degrees simultaneously, making it useful for polynomial fitting and numerical analysis tasks.
