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 Pseudo Vandermonde matrix of the Hermite_e polynomial in Python
To generate a pseudo Vandermonde matrix of the Hermite_e polynomial, use the hermite_e.hermevander2d() in Python NumPy. The method returns the pseudo-Vandermonde matrix. The parameter x and 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 the list of maximum degrees of the form [x_deg, y_deg].
Syntax
numpy.polynomial.hermite_e.hermevander2d(x, y, deg)
Parameters
The parameters for the hermevander2d() function are ?
- x, y ? Arrays of point coordinates with the same shape
- deg ? List of maximum degrees in the format [x_deg, y_deg]
Example
Let's create a complete example to demonstrate generating a pseudo Vandermonde matrix ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create arrays of point coordinates, all of the same shape
x = np.array([1, 2])
y = np.array([3, 4])
# Display the arrays
print("Array1...\n", x)
print("\nArray2...\n", y)
# Display the datatype
print("\nArray1 datatype...\n", x.dtype)
print("\nArray2 datatype...\n", y.dtype)
# Check the Dimensions of both the arrays
print("\nDimensions of Array1...\n", x.ndim)
print("\nDimensions of Array2...\n", y.ndim)
# Check the Shape of both the arrays
print("\nShape of Array1...\n", x.shape)
print("\nShape of Array2...\n", y.shape)
# Generate a pseudo Vandermonde matrix of the Hermite_e polynomial
x_deg, y_deg = 2, 3
result = H.hermevander2d(x, y, [x_deg, y_deg])
print("\nResult...\n", 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,) Result... [[ 1. 3. 8. 18. 1. 3. 8. 18. 0. 0. 0. 0.] [ 1. 4. 15. 52. 2. 8. 30. 104. 3. 12. 45. 156.]]
Understanding the Output
The resulting matrix has shape (2, 12). Each row corresponds to one point coordinate pair (x[i], y[i]), and the columns represent different polynomial terms up to the specified degrees. The matrix contains evaluations of Hermite_e polynomials at the given points.
Different Degree Examples
Let's see how different degree values affect the output ?
import numpy as np
from numpy.polynomial import hermite_e as H
x = np.array([1, 2])
y = np.array([3, 4])
# Lower degree example
result_low = H.hermevander2d(x, y, [1, 1])
print("Degree [1, 1] - Shape:", result_low.shape)
print("Result:\n", result_low)
# Higher degree example
result_high = H.hermevander2d(x, y, [3, 2])
print("\nDegree [3, 2] - Shape:", result_high.shape)
print("Result:\n", result_high)
Degree [1, 1] - Shape: (2, 4) Result: [[ 1. 3. 1. 3.] [ 1. 4. 2. 8.]] Degree [3, 2] - Shape: (2, 12) Result: [[ 1. 3. 8. 1. 3. 8. 0. 0. 0. 3. 9. 24.] [ 1. 4. 15. 2. 8. 30. 3. 12. 45. 8. 32. 120.]]
Conclusion
The hermite_e.hermevander2d() function generates pseudo Vandermonde matrices for Hermite_e polynomials. The output shape depends on the degree parameters, with higher degrees producing larger matrices. This is useful for polynomial fitting and evaluation in two dimensions.
