Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Generate a Pseudo Vandermonde matrix of the Laguerre polynomial and x, y floating array of points in Python
To generate a pseudo Vandermonde matrix of the Laguerre polynomial, use the laguerre.lagvander2d() function in NumPy. This method returns a pseudo-Vandermonde matrix where each element corresponds to a Laguerre polynomial evaluated at the given points.
The pseudo-Vandermonde matrix has shape x.shape + (deg + 1,), where the last index represents the degree of the corresponding Laguerre polynomial. The dtype matches the converted input arrays.
Syntax
numpy.polynomial.laguerre.lagvander2d(x, y, deg)
Parameters
- x, y ? Array of points with coordinates. Converted to float64 or complex128 depending on element types
- deg ? List of maximum degrees in the form [x_deg, y_deg]
Example
Let's create a complete example to generate the pseudo Vandermonde matrix ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create arrays of point coordinates
x = np.array([0.1, 1.4])
y = np.array([1.7, 2.8])
# Display the arrays
print("Array1...")
print(x)
print("\nArray2...")
print(y)
# Display the datatype
print("\nArray1 datatype:", x.dtype)
print("Array2 datatype:", y.dtype)
# Check the dimensions and shape
print("\nDimensions of Array1:", x.ndim)
print("Dimensions of Array2:", y.ndim)
print("\nShape of Array1:", x.shape)
print("Shape of Array2:", y.shape)
# Generate pseudo Vandermonde matrix of Laguerre polynomial
x_deg, y_deg = 2, 3
result = L.lagvander2d(x, y, [x_deg, y_deg])
print("\nPseudo Vandermonde Matrix:")
print(result)
print("\nMatrix shape:", result.shape)
Array1... [0.1 1.4] Array2... [1.7 2.8] Array1 datatype: float64 Array2 datatype: float64 Dimensions of Array1: 1 Dimensions of Array2: 1 Shape of Array1: (2,) Shape of Array2: (2,) Pseudo Vandermonde Matrix: [[ 1. -0.7 -0.955 -0.58383333 0.9 -0.63 -0.8595 -0.52545 0.805 -0.5635 -0.768775 -0.46998583] [ 1. -1.8 -0.68 0.70133333 -0.4 0.72 0.272 -0.28053333 -0.82 1.476 0.5576 -0.57509333]] Matrix shape: (2, 12)
How It Works
The function evaluates Laguerre polynomials of degrees from 0 to the specified maximum degrees at each point combination. For degrees [2, 3], it creates polynomials of the form:
- L?(x) × L?(y), L?(x) × L?(y), ..., L?(x) × L?(y)
- L?(x) × L?(y), L?(x) × L?(y), ..., L?(x) × L?(y)
- L?(x) × L?(y), L?(x) × L?(y), ..., L?(x) × L?(y)
The resulting matrix has dimensions (n_points, (x_deg+1) × (y_deg+1)), which is (2, 12) in our example.
Conclusion
The lagvander2d() function efficiently generates pseudo Vandermonde matrices for 2D Laguerre polynomial fitting. The matrix dimensions depend on the input points and specified polynomial degrees, making it useful for numerical analysis and curve fitting applications.
