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 Vandermonde matrix of the Laguerre polynomial with complex array of points in Python
To generate a pseudo Vandermonde matrix of the Laguerre polynomial with complex points, use the laguerre.lagvander() function from NumPy. This function returns a matrix where each row contains the evaluated Laguerre polynomials of different degrees at a specific point.
Syntax
numpy.polynomial.laguerre.lagvander(x, deg)
Parameters
The function accepts the following parameters ?
- x ? Array of points. The dtype is converted to float64 or complex128 depending on whether any elements are complex
- deg ? Degree of the resulting matrix
Return Value
Returns a pseudo-Vandermonde matrix with shape x.shape + (deg + 1,). The last index corresponds to the degree of the Laguerre polynomial.
Example
Let's create a Vandermonde matrix using complex array points ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create a complex array
x = np.array([-2.+2.j, -1.+2.j, 0.+2.j, 1.+2.j, 2.+2.j])
# Display the array
print("Our Array...\n", x)
# Check the Dimensions
print("\nDimensions of our Array...\n", x.ndim)
# Get the Datatype
print("\nDatatype of our Array object...\n", x.dtype)
# Get the Shape
print("\nShape of our Array object...\n", x.shape)
# Generate the Vandermonde matrix of degree 2
print("\nVandermonde Matrix...\n", L.lagvander(x, 2))
Our Array... [-2.+2.j -1.+2.j 0.+2.j 1.+2.j 2.+2.j] Dimensions of our Array... 1 Datatype of our Array object... complex128 Shape of our Array object... (5,) Vandermonde Matrix... [[ 1. +0.j 3. -2.j 5. -8.j] [ 1. +0.j 2. -2.j 1.5-6.j] [ 1. +0.j 1. -2.j -1. -4.j] [ 1. +0.j 0. -2.j -2.5-2.j] [ 1. +0.j -1. -2.j -3. +0.j]]
How It Works
Each row in the matrix represents the evaluation of Laguerre polynomials L?(x), L?(x), and L?(x) at each complex point. The first column contains L?(x) = 1, the second column contains L?(x) = 1-x, and the third column contains L?(x) = (2-4x+x²)/2.
Conclusion
The lagvander() function efficiently generates Vandermonde matrices for Laguerre polynomials with complex arrays. The resulting matrix has dimensions matching the input array plus one additional dimension for polynomial degrees.
