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 in Python
To generate a Vandermonde matrix of the Hermite_e polynomial, use the hermite_e.hermevander() function in Python NumPy. This method returns a pseudo-Vandermonde matrix where each row corresponds to evaluating Hermite_e polynomials of increasing degrees at a given point.
The shape of the returned matrix is x.shape + (deg + 1,), where the last index represents the degree of the corresponding Hermite_e polynomial. The dtype will match the converted input array x.
Parameters
The function accepts two main parameters:
- x ? Array of points where polynomials are evaluated. Converted to float64 or complex128 depending on element types
- deg ? Degree of the resulting matrix, determining the number of polynomial columns
Basic Example
Here's how to generate a Hermite_e Vandermonde matrix ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of points
x = np.array([0, 1, -1, 2])
# Display the array
print("Our Array...")
print(x)
# Check array properties
print("\nDimensions:", x.ndim)
print("Datatype:", x.dtype)
print("Shape:", x.shape)
# Generate Vandermonde matrix of degree 2
result = H.hermevander(x, 2)
print("\nVandermonde Matrix:")
print(result)
Our Array... [ 0 1 -1 2] Dimensions: 1 Datatype: int64 Shape: (4,) Vandermonde Matrix: [[ 1. 0. -1.] [ 1. 1. 0.] [ 1. -1. 0.] [ 1. 2. 3.]]
Understanding the Output
Each column represents a Hermite_e polynomial degree:
- Column 0 ? Hermite_e polynomial of degree 0 (always 1)
- Column 1 ? Hermite_e polynomial of degree 1 (equals x)
- Column 2 ? Hermite_e polynomial of degree 2 (equals x² - 1)
Different Degrees
You can specify different degrees to get more polynomial evaluations ?
import numpy as np
from numpy.polynomial import hermite_e as H
x = np.array([0, 1, 2])
# Degree 1 matrix
print("Degree 1 matrix:")
print(H.hermevander(x, 1))
print("\nDegree 3 matrix:")
print(H.hermevander(x, 3))
Degree 1 matrix: [[1. 0.] [1. 1.] [1. 2.]] Degree 3 matrix: [[ 1. 0. -1. -0.] [ 1. 1. 0. -2.] [ 1. 2. 3. 2.]]
Conclusion
The hermite_e.hermevander() function efficiently generates Vandermonde matrices for Hermite_e polynomials. Each row evaluates polynomials of degrees 0 to deg at corresponding x values, making it useful for polynomial fitting and numerical computations.
