Generate a Pseudo Vandermonde matrix of the Hermite_e polynomial using NumPy in Python
Last Updated :
03 Jun, 2022
In this article, we will be generating a Pseudo Vandermonde matrix of the Hermite_e polynomial using NumPy in Python.
Example 1:
Generating a Pseudo Vandermonde matrix using hermite_e.hermevander() function
We use the hermite_e.hermevander() function in the Numpy module of python to construct a Vandermonde matrix of the Hermite_e polynomial. The pseudo-Vandermonde matrix is returned by this technique. The returned matrix has the structure x.shape + (deg + 1), where the degree of the associated Hermite e polynomial is the last index. Also the dtype will be similar to converted x.
Syntax : polynomial.hermite_e.hermevander(Arr, deg)
Parameter:
- Arr = It is an array of points.
- deg = It is the degree of the output matrix.
Return: The pseudo-Vandermonde matrix.
Python3
import numpy as np
from numpy.polynomial import hermite_e
Arr = np.array([ 2 , 5 , - 3 , 4 ])
print (hermite_e.hermevander(Arr, 2 ))
|
Output :
[[ 1. 2. 3.]
[ 1. 5. 24.]
[ 1. -3. 8.]
[ 1. 4. 15.]]
Example 2:
Generating a Pseudo Vandermonde matrix using hermite_e.hermevander2d() function
We use the hermite_e.hermevander2d() function present in the NumPy module of python to construct a pseudo Vandermonde matrix of the Hermite_e polynomial. The pseudo-Vandermonde matrix is returned by this technique. The x and y parameters are a set of point coordinates with the same form. Depending on whether any of the elements are complex, the dtypes will be changed to float64 or complex128. Also here scalars are converted into a one-dimensional array. The ‘deg’ parameter is a list of maximum degrees in the format [x deg, y deg].
Syntax : numpy.polynomial.hermite_e.hermevander2d(x, y, deg).
Parameter:
- x,y = These are arrays of the same-shaped point coordinates.
- deg = It is a list of maximum degrees of the form [x_deg, y_deg].
Return: an 2-dimensional array.
Python3
import numpy as np
from numpy.polynomial import hermite_e as H
x = [ 5 , 2 ]
y = [ 3 , 4 ]
deg_of_x = 2
deg_of_y = 3
print (H.hermevander2d(x,y, [deg_of_x, deg_of_y]))
|
Output :
[[ 1. 3. 8. 18. 5. 15. 40. 90. 24. 72. 192. 432.]
[ 1. 4. 15. 52. 2. 8. 30. 104. 3. 12. 45. 156.]]
Example 3:
Generating a Pseudo Vandermonde matrix using hermite_e.hermevander3d() function
To generate a Vandermonde matrix of the Hermite_e polynomial at x, y, and z point coordinates we use hermite_e.hermevander3d() function present in the NumPy module of python. The pseudo-Vandermonde matrix is returned by this technique. x, y, and z are all arrays of point coordinates with the same shape.
Python3
import numpy as np
from numpy.polynomial import hermite_e
x = np.array([ 3 , 1 ])
y = np.array([ 2 , 3 ])
z = np.array([ 4 , 7 ])
deg_of_x = 3
deg_of_y = 2
deg_of_z = 1
print (hermite_e.hermevander3d(x, y, z, [deg_of_x, deg_of_y, deg_of_z]))
|
Output :
[[ 1. 4. 2. 8. 3. 12. 3. 12. 6. 24. 9. 36.
8. 32. 16. 64. 24. 96. 18. 72. 36. 144. 54. 216.]
[ 1. 7. 3. 21. 8. 56. 1. 7. 3. 21. 8. 56.
0. 0. 0. 0. 0. 0. -2. -14. -6. -42. -16. -112.]]
Share your thoughts in the comments
Please Login to comment...