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
Evaluate a 3-D Chebyshev series on the Cartesian product of x, y and z with 4d array of coefficient in Python
To evaluate a 3-D Chebyshev series on the Cartesian product of x, y, z, use the numpy.polynomial.chebyshev.chebgrid3d() method. This function computes the Chebyshev polynomial values at all combinations of the input points.
Syntax
numpy.polynomial.chebyshev.chebgrid3d(x, y, z, c)
Parameters
The parameters are ?
- x, y, z ? Arrays of coordinates. The 3-D series is evaluated at points in the Cartesian product of x, y, and z
- c ? Array of coefficients. If c has fewer than three dimensions, ones are implicitly appended to make it 3-D
Example
Let's create a 4D coefficient array and evaluate the Chebyshev series ?
import numpy as np
from numpy.polynomial import chebyshev as C
# Create a 4d array of coefficients
c = np.arange(48).reshape(2, 2, 6, 2)
# Display the array properties
print("Our Array shape:", c.shape)
print("Dimensions:", c.ndim)
print("Datatype:", c.dtype)
# Evaluate the 3-D Chebyshev series
result = C.chebgrid3d([1, 2], [1, 2], [1, 2], c)
print("\nResult shape:", result.shape)
print("Result:\n", result)
Our Array shape: (2, 2, 6, 2)
Dimensions: 4
Datatype: int64
Result shape: (6, 2, 2, 2, 2)
Result:
[[[[[ 552. 1566.]
[ 576. 1620.]]
[[ 900. 1938.]
[ 936. 2010.]]]
[[[53976. 148176.]
[55956. 152631.]]
[[86904. 235704.]
[89874. 243279.]]]]
[[[[ 972. 2781.]
[1008. 2871.]]
[[ 1584. 3426.]
[ 1638. 3534.]]]
[[[92844. 263244.]
[95814. 271329.]]
[[148176. 418176.]
[152631. 431271.]]]]
[[[[ 1392. 3996.]
[ 1440. 4122.]]
[[ 2268. 4914.]
[ 2340. 5058.]]]
[[[131712. 378312.]
[134652. 389997.]]
[[209448. 600648.]
[215388. 618963.]]]]
[[[[ 1812. 5211.]
[ 1872. 5373.]]
[[ 2952. 6402.]
[ 3042. 6582.]]]
[[[170580. 493380.]
[173490. 508665.]]
[[270720. 783120.]
[278145. 806655.]]]]
[[[[ 2232. 6426.]
[ 2304. 6624.]]
[[ 3636. 7890.]
[ 3744. 8106.]]]
[[[209448. 608448.]
[212328. 627333.]]
[[331992. 965592.]
[341502. 994347.]]]]
[[[[ 2652. 7641.]
[ 2736. 7875.]]
[[ 4320. 9378.]
[ 4446. 9630.]]]
[[[248316. 723516.]
[251166. 746001.]]
[[393264. 1148064.]
[404859. 1182039.]]]]]
How It Works
The function evaluates the 3-D Chebyshev series at every combination of points from the input arrays. The result shape follows the formula: c.shape[3:] + x.shape + y.shape + z.shape. In our example ?
- Coefficient array c has shape (2, 2, 6, 2)
- The first 3 dimensions (2, 2, 6) define the polynomial degrees
- The last dimension (2) represents multiple coefficient sets
- Each input array [1, 2] has shape (2,)
- Final result shape: (6, 2, 2, 2, 2)
Conclusion
The chebgrid3d() function efficiently evaluates 3-D Chebyshev polynomials on Cartesian products of coordinate arrays. The result dimensions depend on both the coefficient array structure and input coordinate shapes.
