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 and x, y, z floating array of points in Python
To generate a pseudo Vandermonde matrix of the Hermite_e polynomial and x, y, z sample points, use the hermite_e.hermevander3d() in Python NumPy. The method returns the pseudo-Vandermonde matrix. The parameter x, y, z 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, z_deg].
Syntax
numpy.polynomial.hermite_e.hermevander3d(x, y, z, deg)
Parameters
x, y, z: Arrays of point coordinates, all of the same shape
deg: List of maximum degrees of the form [x_deg, y_deg, z_deg]
Example
Let's create arrays of point coordinates and generate 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.5, 2.3])
y = np.array([3.7, 4.4])
z = np.array([5.3, 6.6])
# Display the arrays
print("Array1...\n", x)
print("\nArray2...\n", y)
print("\nArray3...\n", z)
# Display the datatype
print("\nArray1 datatype...\n", x.dtype)
print("\nArray2 datatype...\n", y.dtype)
print("\nArray3 datatype...\n", z.dtype)
# Check the Dimensions of the arrays
print("\nDimensions of Array1...\n", x.ndim)
print("\nDimensions of Array2...\n", y.ndim)
print("\nDimensions of Array3...\n", z.ndim)
# Check the Shape of the arrays
print("\nShape of Array1...\n", x.shape)
print("\nShape of Array2...\n", y.shape)
print("\nShape of Array3...\n", z.shape)
# Generate pseudo Vandermonde matrix of the Hermite_e polynomial
x_deg, y_deg, z_deg = 2, 3, 4
result = H.hermevander3d(x, y, z, [x_deg, y_deg, z_deg])
print("\nResult...\n", result)
Array1... [1.5 2.3] Array2... [3.7 4.4] Array3... [5.3 6.6] Array1 datatype... float64 Array2 datatype... float64 Array3 datatype... float64 Dimensions of Array1... 1 Dimensions of Array2... 1 Dimensions of Array3... 1 Shape of Array1... (2,) Shape of Array2... (2,) Shape of Array3... (2,) Result... [[1.00000000e+00 5.30000000e+00 2.70900000e+01 1.32977000e+02 6.23508100e+02 3.70000000e+00 1.96100000e+01 1.00233000e+02 4.92014900e+02 2.30697997e+03 1.26900000e+01 6.72570000e+01 3.43772100e+02 1.68747813e+03 7.91231779e+03 3.95530000e+01 2.09630900e+02 1.07149077e+03 5.25963928e+03 2.46616159e+04 1.50000000e+00 7.95000000e+00 4.06350000e+01 1.99465500e+02 9.35262150e+02 5.55000000e+00 2.94150000e+01 1.50349500e+02 7.38022350e+02 3.46046996e+03 1.90350000e+01 1.00885500e+02 5.15658150e+02 2.53121720e+03 1.18684767e+04 5.93295000e+01 3.14446350e+02 1.60723616e+03 7.88945892e+03 3.69924238e+04 1.25000000e+00 6.62500000e+00 3.38625000e+01 1.66221250e+02 7.79385125e+02 4.62500000e+00 2.45125000e+01 1.25291250e+02 6.15018625e+02 2.88372496e+03 1.58625000e+01 8.40712500e+01 4.29715125e+02 2.10934766e+03 9.89039724e+03 4.94412500e+01 2.62038625e+02 1.33936346e+03 6.57454910e+03 3.08270198e+04] [1.00000000e+00 6.60000000e+00 4.25600000e+01 2.67696000e+02 1.63911360e+03 4.40000000e+00 2.90400000e+01 1.87264000e+02 1.17786240e+03 7.21209984e+03 1.83600000e+01 1.21176000e+02 7.81401600e+02 4.91489856e+03 3.00941257e+04 7.19840000e+01 4.75094400e+02 3.06363904e+03 1.92698289e+04 1.17989953e+05 2.30000000e+00 1.51800000e+01 9.78880000e+01 6.15700800e+02 3.76996128e+03 1.01200000e+01 6.67920000e+01 4.30707200e+02 2.70908352e+03 1.65878296e+04 4.22280000e+01 2.78704800e+02 1.79722368e+03 1.13042667e+04 6.92164891e+04 1.65563200e+02 1.09271712e+03 7.04636979e+03 4.43206064e+04 2.71376893e+05 4.29000000e+00 2.83140000e+01 1.82582400e+02 1.14841584e+03 7.03179734e+03 1.88760000e+01 1.24581600e+02 8.03362560e+02 5.05302970e+03 3.09399083e+04 7.87644000e+01 5.19845040e+02 3.35221286e+03 2.10849148e+04 1.29103799e+05 3.08811360e+02 2.03815498e+03 1.31430115e+04 8.26675658e+04 5.06176900e+05]]
Understanding the Output
The function returns a 2D array where each row corresponds to a point in the input arrays. The number of columns equals (x_deg + 1) * (y_deg + 1) * (z_deg + 1), which in our case is 3 * 4 * 5 = 60 columns. Each column represents the evaluation of a different combination of Hermite_e polynomials at the given points.
Conclusion
The hermite_e.hermevander3d() function generates a pseudo Vandermonde matrix for three-dimensional Hermite_e polynomials. This matrix is useful for polynomial fitting and interpolation problems in three dimensions.
