Evaluate a 3-D Chebyshev series at points (x, y, z) in Python

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

Syntax

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

Parameters

The parameters are:

  • x, y, z − The three dimensional series is evaluated at the points (x, y, z), where x, y, and z must have the same shape. If any of x, y, or z is a list or tuple, it is first converted to an ndarray, otherwise it is left unchanged and if it isn't an ndarray it is treated as a scalar.
  • c − An array of coefficients ordered so that the coefficient of the term of multidegree i,j,k is contained in c[i,j,k]. If c has dimension greater than 3 the remaining indices enumerate multiple sets of coefficients.

Example

Let's create a 3D array of coefficients and evaluate the Chebyshev series at specific points:

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

# Create a 3d array of coefficients
c = np.arange(24).reshape(2, 2, 6)

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

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

# Get the Datatype
print("Datatype of our Array object...", c.dtype)

# Get the Shape
print("Shape of our Array object...", c.shape)

# Evaluate the 3-D Chebyshev series at points (x, y, z)
result = C.chebval3d([1, 2], [1, 2], [1, 2], c)
print("\nResult...")
print(result)
Our Array...
[[[ 0  1  2  3  4  5]
  [ 6  7  8  9 10 11]]

 [[12 13 14 15 16 17]
  [18 19 20 21 22 23]]]

Dimensions of our Array... 3
Datatype of our Array object... int64
Shape of our Array object... (2, 2, 6)

Result...
[ 276. 74088.]

Example with Different Points

Let's evaluate the same series at different coordinate points:

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

# Create coefficients
c = np.arange(8).reshape(2, 2, 2)
print("Coefficient array:")
print(c)

# Evaluate at single point (0, 0, 0)
result_single = C.chebval3d(0, 0, 0, c)
print("\nEvaluation at (0, 0, 0):", result_single)

# Evaluate at multiple points
x_vals = [0, 1]
y_vals = [0, 1] 
z_vals = [0, 1]
result_multiple = C.chebval3d(x_vals, y_vals, z_vals, c)
print("\nEvaluation at multiple points:", result_multiple)
Coefficient array:
[[[0 1]
  [2 3]]

 [[4 5]
  [6 7]]]

Evaluation at (0, 0, 0): 0.0

Evaluation at multiple points: [0. 28.]

Conclusion

The chebval3d() function efficiently evaluates 3D Chebyshev series at specified points. The coefficient array structure determines the polynomial's multidegree terms, making it useful for complex mathematical computations in three dimensions.

Updated on: 2026-03-26T20:54:03+05:30

254 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements