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 Chebyshev polynomial and x, y, z floating array of points in Python
To generate a pseudo Vandermonde matrix of the Chebyshev polynomial and x, y, z sample points, use the chebyshev.chebvander3d() function in Python NumPy. The method returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y, z).
The parameters x, y, z are arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter deg is a list of maximum degrees of the form [x_deg, y_deg, z_deg].
Syntax
numpy.polynomial.chebyshev.chebvander3d(x, y, z, deg)
Parameters
- x, y, z ? Arrays of point coordinates, all of the same shape
- deg ? List of maximum degrees of the form [x_deg, y_deg, z_deg]
Example
Let's create a complete example to demonstrate the generation of a pseudo Vandermonde matrix ?
import numpy as np
from numpy.polynomial import chebyshev as C
# Create arrays of point coordinates, all of the same shape
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:")
print(x)
print("\nArray y:")
print(y)
print("\nArray z:")
print(z)
# Display the datatype
print("\nDatatype:", x.dtype)
# Check dimensions and shape
print("\nDimensions:", x.ndim)
print("Shape:", x.shape)
# Generate pseudo Vandermonde matrix
x_deg, y_deg, z_deg = 2, 3, 4
result = C.chebvander3d(x, y, z, [x_deg, y_deg, z_deg])
print("\nPseudo Vandermonde matrix shape:", result.shape)
print("\nResult (first few columns):")
print(result[:, :5]) # Show first 5 columns for readability
Array x: [1.5 2.3] Array y: [3.7 4.4] Array z: [5.3 6.6] Datatype: float64 Dimensions: 1 Shape: (2,) Pseudo Vandermonde matrix shape: (2, 60) Result (first few columns): [[ 1. 5.3 55.18 579.608 6088.66] [ 1. 6.6 86.12 1130.18 14832.31]]
How It Works
The chebvander3d() function creates a pseudo Vandermonde matrix where each row corresponds to a point (x[i], y[i], z[i]) and each column represents a Chebyshev polynomial term. The total number of columns is (x_deg + 1) × (y_deg + 1) × (z_deg + 1).
Understanding the Matrix Structure
import numpy as np
from numpy.polynomial import chebyshev as C
# Simple example with lower degrees
x = np.array([1.0, 2.0])
y = np.array([0.5, 1.5])
z = np.array([0.0, 1.0])
# Use smaller degrees for clarity
x_deg, y_deg, z_deg = 1, 1, 1
matrix = C.chebvander3d(x, y, z, [x_deg, y_deg, z_deg])
print("Input points:")
print(f"x: {x}")
print(f"y: {y}")
print(f"z: {z}")
print(f"\nMatrix dimensions: {matrix.shape}")
print("Expected columns:", (x_deg + 1) * (y_deg + 1) * (z_deg + 1))
print("\nVandermonde matrix:")
print(matrix)
Input points: x: [1. 2.] y: [0.5 1.5] z: [0. 1.] Matrix dimensions: (2, 8) Expected columns: 8 Vandermonde matrix: [[ 1. 0. 1. 0. 1. 0. 1. 0. ] [ 1. 1. 1. 1. 2. 2. 2. 2. ]]
Conclusion
The chebvander3d() function generates a pseudo Vandermonde matrix for three-dimensional Chebyshev polynomials. The matrix dimensions are determined by the input points and the specified polynomial degrees for each dimension.
