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, 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 parameters x, y, z are arrays of points with the same shape. The parameter deg is a list of maximum degrees of the form [x_deg, y_deg, z_deg].
Syntax
numpy.polynomial.laguerre.lagvander3d(x, y, z, deg)
Parameters
The function accepts the following parameters ?
- x, y, z − Arrays of point coordinates, all of the same shape
- deg − List of maximum degrees [x_deg, y_deg, z_deg]
Example
Let's create arrays of point coordinates and generate the pseudo Vandermonde matrix ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create arrays of point coordinates
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("Array x:", x)
print("Array y:", y)
print("Array z:", z)
# Display array properties
print("\nArray datatypes:")
print("x dtype:", x.dtype)
print("y dtype:", y.dtype)
print("z dtype:", z.dtype)
print("\nArray shapes:")
print("x shape:", x.shape)
print("y shape:", y.shape)
print("z shape:", z.shape)
# Generate pseudo Vandermonde matrix
x_deg, y_deg, z_deg = 2, 3, 4
result = L.lagvander3d(x, y, z, [x_deg, y_deg, z_deg])
print("\nPseudo Vandermonde matrix shape:", result.shape)
print("Result matrix:")
print(result)
Array x: [1.5 2.3] Array y: [3.7 4.4] Array z: [5.3 6.6] Array datatypes: x dtype: float64 y dtype: float64 z dtype: float64 Array shapes: x shape: (2,) y shape: (2,) z shape: (2,) Pseudo Vandermonde matrix shape: (2, 60) Result matrix: [[ 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]]
How It Works
The lagvander3d() function creates a 3D pseudo Vandermonde matrix where each row corresponds to a point (x[i], y[i], z[i]) and each column represents a combination of Laguerre polynomial basis functions. The matrix has shape (n_points, (x_deg+1)*(y_deg+1)*(z_deg+1)), where n_points is the number of coordinate points.
Conclusion
Use numpy.polynomial.laguerre.lagvander3d() to generate pseudo Vandermonde matrices for 3D Laguerre polynomial fitting. The function requires coordinate arrays of equal shape and degree specifications for each dimension.
