Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y, z floating array of points in Python


To generate a pseudo Vandermonde matrix of the Laguerre polynomial with x, y, z sample points, use the laguerre.lagvander3d() in Python Numpy. The parameter, x, y, z returns an Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array. 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 laguerre as L

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

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 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 Laguerre polynomial with x, y, z sample points, use the laguerre.lagvander3d() in Python −

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

Example

import numpy as np
from numpy.polynomial import laguerre as L

# Create arrays of point coordinates, all of the same shape using the numpy.array() method
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 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 Laguerre polynomial with x, y, z sample points, use the laguerre.lagvander3d() in Python Numpy

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

Output

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.          -4.3        4.445       2.42216667 -2.30432917
    -2.7          11.61     -12.0015    -6.53985     6.22168875
     0.445       -1.9135     1.978025    1.07786417 -1.02542648
     1.99283333  -8.56918333 8.85814417  4.82697447 -4.59214397
    -0.5          2.15      -2.2225     -1.21108333  1.15216458
     1.35        -5.805      6.00075     3.269925   -3.11084437
    -0.2225       0.95675   -0.9890125  -0.53893208  0.51271324
    -0.99641667  4.28459167 -4.42907208 -2.41348724  2.29607199
    -0.875       3.7625     -3.889375   -2.11939583  2.01628802
     2.3625     -10.15875   10.5013125   5.72236875 -5.44397766
   -0.389375     1.6743125  -1.73077188 -0.94313115  0.89724817
   -1.74372917   7.49803542 -7.75087615 -4.22360266  4.01812598]
  [ 1.          -5.6         9.58       -1.376      -7.3226
   -3.4         19.04      -32.572       4.6784      24.89684
    1.88       -10.528      18.0104     -2.58688    -13.766488
    2.64266667 -14.79893333 25.31674667 -3.63630933 -19.35119093
   -1.3         7.28       -12.454       1.7888      9.51938
    4.42       -24.752      42.3436     -6.08192    -32.365892
   -2.444      13.6864     -23.41352     3.362944    17.8964344
   -3.43546667 19.23861333 -32.91177067  4.72720213  25.15654821
   -0.955      5.348       -9.1489       1.31408     6.993083
    3.247     -18.1832     31.10626     -4.467872   -23.7764822
   -1.7954     10.05424    -17.199932    2.4704704   13.14699604
   -2.52374667 14.13298133 -24.17749307  3.47267541  18.48038734]]

Updated on: 07-Mar-2022

66 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements