Evaluate a 3-D Chebyshev series at points (x, y, z) with 2D array of coefficient in Python

To evaluate a 3-D Chebyshev series at points (x, y, z), use the polynomial.chebval3d() method in Python NumPy. The method returns the values of the multidimensional polynomial on points formed with triples of corresponding values from x, y, and z.

The parameters are x, y, z arrays representing the three dimensional coordinates where the series is evaluated. The points (x, y, z) must have the same shape. The parameter c is an array of coefficients ordered so that the coefficient of the term of multi-degree i,j,k is contained in c[i,j,k].

Syntax

numpy.polynomial.chebyshev.chebval3d(x, y, z, c)

Parameters

  • x, y, z ? Arrays of coordinates. Must have the same shape
  • c ? Array of coefficients ordered for multi-degree terms

Example

Let's create a 2D array of coefficients and evaluate the 3D Chebyshev series ?

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

# Create a 2D array of coefficients
c = np.arange(4).reshape(2, 2)

# Display the array
print("Our Array...")
print(c)

# Check the dimensions
print("\nDimensions of our Array...")
print(c.ndim)

# Get the datatype
print("\nDatatype of our Array object...")
print(c.dtype)

# Get the shape
print("\nShape of our Array object...")
print(c.shape)

# Evaluate 3-D Chebyshev series at points (x, y, z)
print("\nResult...")
print(C.chebval3d([1, 2], [1, 2], [1, 2], c))
Our Array...
[[0 1]
 [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

Shape of our Array object...
(2, 2)

Result...
[24. 42.]

How It Works

The function evaluates the 3D Chebyshev polynomial using the coefficient matrix. For each point (x[i], y[i], z[i]), it computes the sum of products of Chebyshev basis functions and their corresponding coefficients. The result array contains the evaluated values at each coordinate point.

Example with Different Points

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

# Create coefficient array
coefficients = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])

# Define evaluation points
x_points = [0, 1]
y_points = [0, 1] 
z_points = [0, 1]

# Evaluate the series
result = C.chebval3d(x_points, y_points, z_points, coefficients)
print("Result at points:", result)
Result at points: [1. 8.]

Conclusion

The chebval3d() function efficiently evaluates 3D Chebyshev series at specified coordinate points. It's useful for multidimensional polynomial approximations and requires matching shapes for x, y, z coordinates.

Updated on: 2026-03-26T19:46:30+05:30

213 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements