Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y, z complex 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() method in NumPy. This function creates a three-dimensional Vandermonde matrix where each element corresponds to the evaluation of Laguerre polynomials at the given complex points.

Syntax

numpy.polynomial.laguerre.lagvander3d(x, y, z, deg)

Parameters

The function accepts the following parameters:

  • x, y, z ? Arrays of point coordinates. The dtype is converted to float64 or complex128 depending on whether any elements are complex
  • deg ? List of maximum degrees of the form [x_deg, y_deg, z_deg]

Example

Let's create a complete example that demonstrates how to generate a pseudo Vandermonde matrix ?

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

# Create arrays of complex point coordinates
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("Array x:", x)
print("Array y:", y)
print("Array z:", z)

# Display datatypes
print("\nDatatype x:", x.dtype)
print("Datatype y:", y.dtype)  
print("Datatype z:", z.dtype)

# Check dimensions and shapes
print("\nDimensions - x:", x.ndim, "y:", y.ndim, "z:", z.ndim)
print("Shapes - x:", x.shape, "y:", y.shape, "z:", z.shape)

# Generate pseudo Vandermonde matrix with degrees [2, 3, 4]
x_deg, y_deg, z_deg = 2, 3, 4
result = L.lagvander3d(x, y, z, [x_deg, y_deg, z_deg])

print(f"\nVandermonde matrix shape: {result.shape}")
print("Result:\n", result)
Array x: [-2.+2.j -1.+2.j]
Array y: [0.+2.j 1.+2.j]
Array z: [2.+2.j 3.+3.j]

Datatype x: complex128
Datatype y: complex128
Datatype z: complex128

Dimensions - x: 1 y: 1 z: 1
Shapes - x: (2,) y: (2,) z: (2,)

Vandermonde matrix shape: (2, 60)
Result:
[[ 1.        +0.j         -1.        -2.j        -3.        +0.j
  -2.33333333+3.33333333j  1.        +5.33333333j  1.        -2.j
  -5.        +0.j         -3.        +6.j         4.33333333+8.j
  11.66666667+3.33333333j -1.        -4.j        -7.        +6.j
   3.        +12.j        15.66666667+6.j        20.33333333-9.33333333j
  -5.        -4.66666667j -4.33333333+14.66666667j 15.        +14.j
  27.22222222-5.77777778j 19.88888889-31.33333333j  3.        -2.j
  -7.        -4.j         -9.        +6.j        -0.33333333+14.66666667j
  13.66666667+14.j        -1.        -8.j        -15.        +10.j
   3.        +24.j        29.        +15.33333333j 41.66666667-13.33333333j
 -11.        -10.j        -9.        +32.j        33.        +30.j
  59.        -13.33333333j 42.33333333-68.66666667j -24.33333333-4.j
  16.33333333+52.66666667j 73.        +12.j        70.11111111-71.77777778j
  -3.        -133.77777778j  5.        -8.j        -21.        -2.j
 -15.        +24.j        15.        +35.33333333j 47.66666667+18.66666667j
 -11.        -18.j        -25.        +40.j        33.        +54.j
  85.66666667+5.33333333j  85.        -76.66666667j -37.        -12.j
  13.        +86.j        111.        +36.j        126.33333333-95.33333333j
  27.        -209.33333333j -62.33333333+16.66666667j 95.66666667+108.j
 187.        -50.j        89.88888889-246.66666667j -151.22222222-315.77777778j]
 [ 1.        +0.j         -2.        -3.j        -5.        +3.j
   1.        +9.j         11.5       +6.j         0.        -2.j
  -6.        +4.j          6.        +10.j        18.        -2.j
  12.        -23.j        -2.5       -2.j        -1.        +11.5j
  18.5       +2.5j        15.5       -24.5j      -16.75      -38.j
  -4.66666667+0.33333333j 10.33333333+13.33333333j 22.33333333-15.66666667j
  -7.66666667-41.66666667j -55.66666667-24.16666667j  2.        -2.j
 -10.        -2.j         -4.        +16.j        20.        +16.j
  35.        -11.j        -4.        -4.j         -4.        +20.j
  32.        +8.j         32.        -40.j        -22.        -70.j
  -9.        +1.j         21.        +25.j        42.        -32.j
 -18.        -80.j        -109.5      -42.5j       -8.66666667+10.j
  47.33333333+6.j         13.33333333-76.j        -98.66666667-68.j
 -159.66666667+63.j        1.5        -6.j        -21.        +7.5j
  10.5       +34.5j        55.5       +7.5j        53.25      -60.j
 -12.        -3.j         15.        +42.j        69.        -21.j
  15.        -111.j       -120.       -106.5j      -15.75      +12.j
  67.5       +23.25j       42.75      -107.25j     -123.75     -129.75j
 -253.125    +43.5j        -5.        +28.5j       95.5       -42.j
 -60.5       -157.5j      -261.5      -16.5j      -228.5      +297.75j]]

How It Works

The lagvander3d() function creates a three-dimensional Vandermonde matrix by:

  • Evaluating Laguerre polynomials of degrees 0 to x_deg for each x coordinate
  • Evaluating Laguerre polynomials of degrees 0 to y_deg for each y coordinate
  • Evaluating Laguerre polynomials of degrees 0 to z_deg for each z coordinate
  • Computing the tensor product of these evaluations to form the final matrix

Matrix Dimensions

The resulting matrix has dimensions (len(x), (x_deg+1)*(y_deg+1)*(z_deg+1)). In our example with degrees [2,3,4], this gives us a matrix of shape (2, 60) since (2+1)*(3+1)*(4+1) = 3*4*5 = 60.

Conclusion

The lagvander3d() function efficiently generates pseudo Vandermonde matrices for three-dimensional Laguerre polynomial evaluation. This is particularly useful for polynomial fitting and interpolation in three-dimensional complex spaces.

Updated on: 2026-03-26T20:07:06+05:30

210 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements