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 polynomial in Python
To generate a Vandermonde matrix of the Hermite polynomial, use the hermite.hermvander() function in Python NumPy. This method returns a pseudo-Vandermonde matrix where each row corresponds to a point and each column represents increasing degrees of Hermite polynomials.
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 matches the converted input array x.
Parameters
x: Array of points where the dtype is converted to float64 or complex128 depending on whether any elements are complex. Scalar values are converted to 1-D arrays.
deg: The degree of the resulting matrix, determining the number of polynomial columns.
Syntax
numpy.polynomial.hermite.hermvander(x, deg)
Example
Let's create a Vandermonde matrix for Hermite polynomials up to degree 2 ?
import numpy as np
from numpy.polynomial import hermite as H
# Create an array
x = np.array([0, 1, -1, 2])
# Display the array
print("Our Array...\n", x)
# Check the Dimensions
print("\nDimensions of our Array...\n", x.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n", x.dtype)
# Get the Shape
print("\nShape of our Array object...\n", x.shape)
# To generate a Vandermonde matrix of the Hermite polynomial, use hermite.hermvander()
print("\nResult...\n", H.hermvander(x, 2))
Our Array... [ 0 1 -1 2] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (4,) Result... [[ 1. 0. -2.] [ 1. 2. 2.] [ 1. -2. 2.] [ 1. 4. 14.]]
How It Works
The Vandermonde matrix contains Hermite polynomial values where:
- Column 0: H?(x) = 1 (degree 0)
- Column 1: H?(x) = 2x (degree 1)
- Column 2: H?(x) = 4x² - 2 (degree 2)
For each input point, the function evaluates all Hermite polynomials up to the specified degree.
Conclusion
The hermite.hermvander() function generates a Vandermonde matrix for Hermite polynomials, useful in polynomial fitting and numerical analysis. Each row represents evaluations at a specific point, while columns represent increasing polynomial degrees.
