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 and hermite_e libraries
import numpy as np
from numpy.polynomial import hermite_e
# Create an one dimensional array 'Arr'
Arr = np.array([2, 5, -3, 4])
# To generate a Vandermonde matrix of the
# Hermite_e polynomial,
# use the hermite_e.hermevander() method
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 and hermite_e libraries
import numpy as np
from numpy.polynomial import hermite_e as H
# Now create arrays of point coordinates x and y
x = [5, 2]
y = [3, 4]
# Define the degrees of x and y
deg_of_x = 2
deg_of_y = 3
# To generate a pseudo Vandermonde matrix of
# the Hermite_e polynomial,
# use the hermite_e.hermevander2d() method
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 and hermite_e libraries
import numpy as np
from numpy.polynomial import hermite_e
# Now create arrays of point coordinates
# x, y and z
x = np.array([3, 1])
y = np.array([2, 3])
z = np.array([4, 7])
# assign the degree to x, y and z
deg_of_x = 3
deg_of_y = 2
deg_of_z = 1
# use the hermite.hermevander3d() function
# to generate a pseudo Vandermonde
# matrix of the Hermite_e polynomial
# and x, y, z as the sample points
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.]]
Similar Reads
Generate a Vandermonde matrix of given degree using NumPy in Python In this article, we will cover generating a Vandermonde matrix of a given degree in Python using NumPy. In algebra, a Vandermonde matrix is an m*n matrix that has the terms of a geometric progression in each row. The matrix generated will be of the form : [1 x11 x12 ........ x1(n-1) ................
3 min read
Generate a Vandermonde matrix of the Chebyshev polynomial in Python In this article, we will be looking at the approach using various functionalities of the Numpy packages to generate a Vandermonde matrix of the Chebyshev polynomial in Python. NumPy.chebvander method To generate a Vandermonde matrix of the Chebyshev polynomial, the user needs to call the np.chebvand
3 min read
Generate a Pseudo Vandermonde matrix of the Chebyshev and Legendre polynomial in Python In this article, we will generate a Pseudo Vandermonde matrix of the Chebyshev and Legendre polynomial x, y, and z floating array of points in Python. Example 1 Generating a Pseudo Vandermonde matrix of Legendre..legvander3d() function We use the legendre.legvander3d() method present in the Numpy mo
4 min read
Generate a Vandermonde matrix of the Legendre series in Python using NumPy In this article, we will be looking toward the approach to generating a Vandermonde matrix of the Legendre series in Python using NumPy. Example: Array: [-1 2 -3 4 -5] Result: [[ 1. -1. 1. ] [ 1. 2. 5.5] [ 1. -3. 13. ] [ 1. 4. 23.5] [ 1. -5. 37. ]]NumPy.legvander() To generate a pseudo Vandermonde m
3 min read
Generate a Vandermonde Matrix of the Legendre Polynomial with Float Array of Points in Python using NumPy In this article, we will be looking at the approach to generating a Vandermonde matrix of the Legendre polynomial with a float array of points in Python using NumPy. Example: Array: [-1.57 0.58 -3.57 1.44 2.75] Result: [[ 1.000000e+00 -1.570000e+00 3.197350e+00] [ 1.000000e+00 5.800000e-01 4.600000e
3 min read
Convert a polynomial to Hermite_e series using NumPy in Python In this article, we will cover how to convert a polynomial to Hermite_e series using NumPy in Python. hermite_e.poly2herme method We use the hermite_e.poly2herme() function present in the NumPy module of python to convert a polynomial to a Hermite series. Here we need to convert an array of polynomi
2 min read