
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y, z complex array of points in Python
To generate a pseudo Vandermonde matrix of the Legendre polynomial with x, y, z sample points, use the legendre.legvander3d() method in Python Numpy. Returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y, z).
The parameters, 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 a 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 legendre as L
Create arrays of point coordinates, all of the same shape using the numpy.array() method −
x = np.array([-2.+2.j, -1.+2.j]) y = np.array([0.+2.j, 1.+2.j]) z = np.array([2.+2.j, 3. + 3.j])
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 Legendre polynomial with x, y, z sample points, use the legendre.legvander3d() method in Python Numpy −
x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))
Example
import numpy as np from numpy.polynomial import legendre as L # Create arrays of point coordinates, all of the same shape using the numpy.array() method x = np.array([-2.+2.j, -1.+2.j]) y = np.array([0.+2.j, 1.+2.j]) z = np.array([2.+2.j, 3. + 3.j]) # 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 Legendre polynomial with x, y, z sample points, use the legendre.legvander3d() method in Python Numpy x_deg, y_deg, z_deg = 2, 3, 4 print("\nResult...\n",L.legvander3d(x,y,z, [x_deg, y_deg, z_deg]))
Output
Array1... [-2.+2.j -1.+2.j] Array2... [0.+2.j 1.+2.j] Array3... [2.+2.j 3.+3.j] Array1 datatype... complex128 Array2 datatype... complex128 Array3 datatype... complex128 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 +0.0000000e+00j 2.00000000e+00 +2.0000000e+00j -5.00000000e-01 +1.2000000e+01j -4.30000000e+01 +3.7000000e+01j -2.79625000e+02 -3.0000000e+01j 0.00000000e+00 +2.0000000e+00j -4.00000000e+00 +4.0000000e+00j -2.40000000e+01 -1.0000000e+00j -7.40000000e+01 -8.6000000e+01j 6.00000000e+01 -5.5925000e+02j -6.50000000e+00 +0.0000000e+00j -1.30000000e+01 -1.3000000e+01j 3.25000000e+00 -7.8000000e+01j 2.79500000e+02 -2.4050000e+02j 1.81756250e+03 +1.9500000e+02j 0.00000000e+00 -2.3000000e+01j 4.60000000e+01 -4.6000000e+01j 2.76000000e+02 +1.1500000e+01j 8.51000000e+02 +9.8900000e+02j -6.90000000e+02 +6.4313750e+03j -2.00000000e+00 +2.0000000e+00j -8.00000000e+00 +0.0000000e+00j -2.30000000e+01 -2.5000000e+01j 1.20000000e+01 -1.6000000e+02j 6.19250000e+02 -4.9925000e+02j -4.00000000e+00 -4.0000000e+00j 0.00000000e+00 -1.6000000e+01j 5.00000000e+01 -4.6000000e+01j 3.20000000e+02 +2.4000000e+01j 9.98500000e+02 +1.2385000e+03j 1.30000000e+01 -1.3000000e+01j 5.20000000e+01 +0.0000000e+00j 1.49500000e+02 +1.6250000e+02j -7.80000000e+01 +1.0400000e+03j -4.02512500e+03 +3.2451250e+03j 4.60000000e+01 +4.6000000e+01j 0.00000000e+00 +1.8400000e+02j -5.75000000e+02 +5.2900000e+02j -3.68000000e+03 -2.7600000e+02j -1.14827500e+04 -1.4242750e+04j -5.00000000e-01 -1.2000000e+01j 2.30000000e+01 -2.5000000e+01j 1.44250000e+02 +0.0000000e+00j 4.65500000e+02 +4.9750000e+02j -2.20187500e+02 +3.3705000e+03j 2.40000000e+01 -1.0000000e+00j 5.00000000e+01 +4.6000000e+01j 0.00000000e+00 +2.8850000e+02j -9.95000000e+02 +9.3100000e+02j -6.74100000e+03 -4.4037500e+02j 3.25000000e+00 +7.8000000e+01j -1.49500000e+02 +1.6250000e+02j -9.37625000e+02 +0.0000000e+00j -3.02575000e+03 -3.2337500e+03j 1.43121875e+03 -2.1908250e+04j -2.76000000e+02 +1.1500000e+01j -5.75000000e+02 -5.2900000e+02j 0.00000000e+00 -3.3177500e+03j 1.14425000e+04 -1.0706500e+04j 7.75215000e+04 +5.0643125e+03j] [ 1.00000000e+00 +0.0000000e+00j 3.00000000e+00 +3.0000000e+00j -5.00000000e-01 +2.7000000e+01j -1.39500000e+02 +1.3050000e+02j -1.41712500e+03 -6.7500000e+01j 1.00000000e+00 +2.0000000e+00j -3.00000000e+00 +9.0000000e+00j -5.45000000e+01 +2.6000000e+01j -4.00500000e+02 -1.4850000e+02j -1.28212500e+03 -2.9017500e+03j -5.00000000e+00 +6.0000000e+00j -3.30000000e+01 +3.0000000e+00j -1.59500000e+02 -1.3800000e+02j -8.55000000e+01 -1.4895000e+03j 7.49062500e+03 -8.1652500e+03j -2.90000000e+01 -8.0000000e+00j -6.30000000e+01 -1.1100000e+02j 2.30500000e+02 -7.7900000e+02j 5.08950000e+03 -2.6685000e+03j 4.05566250e+04 +1.3294500e+04j -1.00000000e+00 +2.0000000e+00j -9.00000000e+00 +3.0000000e+00j -5.35000000e+01 -2.8000000e+01j -1.21500000e+02 -4.0950000e+02j 1.55212500e+03 -2.7667500e+03j -5.00000000e+00 +0.0000000e+00j -1.50000000e+01 -1.5000000e+01j 2.50000000e+00 -1.3500000e+02j 6.97500000e+02 -6.5250000e+02j 7.08562500e+03 +3.3750000e+02j -7.00000000e+00 -1.6000000e+01j 2.70000000e+01 -6.9000000e+01j 4.35500000e+02- 1.8100000e+02j 3.06450000e+03 +1.3185000e+03j 8.83987500e+03 +2.3146500e+04j 4.50000000e+01 -5.0000000e+01j 2.85000000e+02 -1.5000000e+01j 1.32750000e+03 +1.2400000e+03j 2.47500000e+02 +1.2847500e+04j -6.71456250e+04 +6.7818750e+04j -5.00000000e+00 -6.0000000e+00j 3.00000000e+00 -3.3000000e+01j 1.64500000e+02 -1.3200000e+02j 1.48050000e+03 +1.8450000e+02j 6.68062500e+03 +8.8402500e+03j 7.00000000e+00 -1.6000000e+01j 6.90000000e+01 -2.7000000e+01j 4.28500000e+02 +1.9700000e+02j 1.11150000e+03 +3.1455000e+03j -1.09998750e+04 +2.2201500e+04j 6.10000000e+01 +0.0000000e+00j 1.83000000e+02 +1.8300000e+02j -3.05000000e+01 +1.6470000e+03j -8.50950000e+03 +7.9605000e+03j -8.64446250e+04 -4.1175000e+03j 9.70000000e+01 +2.1400000e+02j -3.51000000e+02 +9.3300000e+02j -5.82650000e+03 +2.5120000e+03j -4.14585000e+04 -1.7194500e+04j -1.23016125e+05 -3.0981225e+05j]]
- Related Articles
- Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y complex array of points in Python
- Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y, z array of points in Python
- Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y, z floating array of points in Python
- Generate a Pseudo Vandermonde matrix of the Hermite polynomial and x, y, z complex array of points in Python
- Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y, z complex array of points in Python
- Generate a Pseudo Vandermonde matrix of the Hermite_e polynomial and x, y, z complex array of points in Python
- Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y array of points in Python
- Generate a Pseudo Vandermonde matrix of the Legendre polynomial and x, y floating array of points in Python
- Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y complex array of points in Python
- Generate a Pseudo-Vandermonde matrix of given degree and x, y, z complex array of points in Python
- Generate a pseudo Vandermonde matrix of Chebyshev polynomial and x, y, z floating array of points in Python
- Generate a Pseudo Vandermonde matrix of Hermite polynomial and x, y, z floating array of points in Python
- Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y, z floating array of points in Python
- Generate a Pseudo Vandermonde matrix of the Hermite_e polynomial and x, y, z floating array of points in Python
- Generate a pseudo Vandermonde matrix of the Chebyshev polynomial and x, y, z sample points in Python
