Generate a pseudo Vandermonde matrix of the Chebyshev polynomial in Python

To generate a pseudo Vandermonde matrix of the Chebyshev polynomial, use the chebyshev.chebvander2d() function in NumPy. This method returns the pseudo-Vandermonde matrix of degrees deg and sample points (x, y).

The parameters x and y 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].

Syntax

numpy.polynomial.chebyshev.chebvander2d(x, y, deg)

Parameters

  • x, y − Arrays of point coordinates with the same shape
  • deg − List of maximum degrees in the form [x_deg, y_deg]

Example

Let's create a complete example to generate a pseudo Vandermonde matrix of Chebyshev polynomial ?

import numpy as np
from numpy.polynomial import chebyshev as C

# Create arrays of point coordinates
x = np.array([1, 2])
y = np.array([3, 4])

# Display the arrays
print("Array1...\n", x)
print("\nArray2...\n", y)

# Display the datatype
print("\nArray1 datatype...\n", x.dtype)
print("\nArray2 datatype...\n", y.dtype)

# Check the dimensions and shape
print("\nDimensions of Array1...\n", x.ndim)
print("\nShape of Array1...\n", x.shape)

# Generate pseudo Vandermonde matrix of Chebyshev polynomial
x_deg, y_deg = 2, 3
result = C.chebvander2d(x, y, [x_deg, y_deg])
print("\nResult...\n", result)
Array1...
 [1 2]

Array2...
 [3 4]

Array1 datatype...
 int64

Array2 datatype...
 int64

Dimensions of Array1...
 1

Shape of Array1...
 (2,)

Result...
 [[1.000e+00 3.000e+00 1.700e+01 9.900e+01 1.000e+00 3.000e+00 1.700e+01
  9.900e+01 1.000e+00 3.000e+00 1.700e+01 9.900e+01]
 [1.000e+00 4.000e+00 3.100e+01 2.440e+02 2.000e+00 8.000e+00 6.200e+01
  4.880e+02 7.000e+00 2.800e+01 2.170e+02 1.708e+03]]

How It Works

The chebvander2d() function creates a matrix where each row corresponds to a point (x[i], y[i]) and each column represents a Chebyshev polynomial basis function. The degrees specify the maximum powers in each dimension, creating a grid of polynomial terms up to the specified degrees.

Key Points

  • The resulting matrix has shape (len(x), (x_deg+1)*(y_deg+1))
  • Each element represents the evaluation of a specific Chebyshev polynomial term
  • Useful for polynomial fitting and approximation in two dimensions

Conclusion

Use numpy.polynomial.chebyshev.chebvander2d() to generate pseudo Vandermonde matrices for Chebyshev polynomials. This function is essential for polynomial approximation and fitting in two-dimensional spaces.

Updated on: 2026-03-26T19:29:17+05:30

211 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements