# Generate a Pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points in Python

PythonNumpyServer Side ProgrammingProgramming

To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() 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].

## Steps

At first, import the required library −

import numpy as np
from numpy.polynomial import hermite as H

Create arrays of point coordinates, all of the same shape using the numpy.array() method −

x = np.array([1, 2])
y = np.array([3, 4])
z = np.array([5, 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 both 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 both the arrays −

print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)

# To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() −

x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermvander3d(x,y,z, [x_deg, y_deg, z_deg]))

## Example

import numpy as np
from numpy.polynomial import hermite as H

# Create arrays of point coordinates, all of the same shape using the numpy.array() method
x = np.array([1, 2])
y = np.array([3, 4])
z = np.array([5, 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 both 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 both the arrays
print("\nShape of Array1...\n",x.shape)
print("\nShape of Array2...\n",y.shape)
print("\nShape of Array3...\n",z.shape)

# To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() in Python Numpy
# The method returns the pseudo-Vandermonde matrix.

x_deg, y_deg, z_deg = 2, 3, 4
print("\nResult...\n",H.hermvander3d(x,y,z, [x_deg, y_deg, z_deg]))

## Output

Array1...
[1 2]

Array2...
[3 4]

Array3...
[5 6]

Array1 datatype...
int64

Array2 datatype...
int64

Array3 datatype...
int64

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.0000000e+00 1.0000000e+01 9.8000000e+01 9.4000000e+02 8.8120000e+03
6.0000000e+00 6.0000000e+01 5.8800000e+02 5.6400000e+03 5.2872000e+04
3.4000000e+01 3.4000000e+02 3.3320000e+03 3.1960000e+04 2.9960800e+05
1.8000000e+02 1.8000000e+03 1.7640000e+04 1.6920000e+05 1.5861600e+06
2.0000000e+00 2.0000000e+01 1.9600000e+02 1.8800000e+03 1.7624000e+04
1.2000000e+01 1.2000000e+02 1.1760000e+03 1.1280000e+04 1.0574400e+05
6.8000000e+01 6.8000000e+02 6.6640000e+03 6.3920000e+04 5.9921600e+05
3.6000000e+02 3.6000000e+03 3.5280000e+04 3.3840000e+05 3.1723200e+06
2.0000000e+00 2.0000000e+01 1.9600000e+02 1.8800000e+03 1.7624000e+04
1.2000000e+01 1.2000000e+02 1.1760000e+03 1.1280000e+04 1.0574400e+05
6.8000000e+01 6.8000000e+02 6.6640000e+03 6.3920000e+04 5.9921600e+05
3.6000000e+02 3.6000000e+03 3.5280000e+04 3.3840000e+05 3.1723200e+06]
[1.0000000e+00 1.2000000e+01 1.4200000e+02 1.6560000e+03 1.9020000e+04
8.0000000e+00 9.6000000e+01 1.1360000e+03 1.3248000e+04 1.5216000e+05
6.2000000e+01 7.4400000e+02 8.8040000e+03 1.0267200e+05 1.1792400e+06
4.6400000e+02 5.5680000e+03 6.5888000e+04 7.6838400e+05 8.8252800e+06
4.0000000e+00 4.8000000e+01 5.6800000e+02 6.6240000e+03 7.6080000e+04
3.2000000e+01 3.8400000e+02 4.5440000e+03 5.2992000e+04 6.0864000e+05
2.4800000e+02 2.9760000e+03 3.5216000e+04 4.1068800e+05 4.7169600e+06
1.8560000e+03 2.2272000e+04 2.6355200e+05 3.0735360e+06 3.5301120e+07
1.4000000e+01 1.6800000e+02 1.9880000e+03 2.3184000e+04 2.6628000e+05
1.1200000e+02 1.3440000e+03 1.5904000e+04 1.8547200e+05 2.1302400e+06
8.6800000e+02 1.0416000e+04 1.2325600e+05 1.4374080e+06 1.6509360e+07
6.4960000e+03 7.7952000e+04 9.2243200e+05 1.0757376e+07 1.2355392e+08]]