Skip to content
Related Articles

Related Articles

Evaluate a 3-D Chebyshev series on the Cartesian product of x, y and z with 2d array of coefficient

View Discussion
Improve Article
Save Article
  • Last Updated : 22 Apr, 2022

In this article, we will discuss how to evaluate a 3-D Chebyshev series on the Cartesian product of x, y, and z with a 2d array of coefficients in Python and NumPy.

Example

Input: [[0 1]
[2 3]]

Output: [[17. 28.]
[28. 46.]]

Explanation: A 3-D Chebyshev series on the Cartesian product.

With the help of NumPy.polynomial.Chebyshev.chebgrid3d() method, we can get the array of coefficients after evaluating the Chebyshev series on the cartesian product of x, y, and z by using the np.chebgrid3d() method. Here, x, y, and z are tuples or lists, they are converted to arrays. These elements must be capable of multiplication and addition among themselves as well as with the constituents of c. If the shape of the c has fewer than three dimensions, ones are implicitly added to make it three-dimensional.

Syntax: numpy.polynomial.chebyshev.chebgrid3d()

Parameters:

  • x,y,z: array like objects. The points in the Cartesian product of x, y, and z are used to assess the three-dimensional series. 
  • c: The coefficients for terms of degree i,j are contained in c[i,j].

Returns: values: array like object

Example 1:

Here, the NumPy package is imported and np.array() is used to create a 2-d array the .shape attribute is used to find the shape of the array, the .ndim attribute is used to find the dimensions of the array, the .dtype attribute is used to find the data type of the array and numpy.polynomial.chebyshev.chebgrid3d() is used to evaluate the 3-d Chebyshev series.

Python3




# import packages
import numpy as np
from numpy.polynomial import chebyshev as Chev
  
# array of coefficients
c = np.array([[2,2],[3,3]])
print(c)
  
# shape of the array is
print("Shape of the array is : ",c.shape)
  
# dimension of the array
print("The dimension of the array is : ",c.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",c.dtype)
  
#evaluating Chebyshev series
print(Chev.chebgrid3d([1,2],[3,4],[5,6],c))

Output:

[[2 2]
 [3 3]]
Shape of the array is :  (2, 2)
The dimension of the array is :  2
Datatype of our Array is :  int64
[[180. 212.]
 [225. 265.]]

Example 2:

In this example, we are using a 1-D array to evaluate a 3-D Chebyshev series on the Cartesian product series.

Python3




# import packages
import numpy as np
from numpy.polynomial import chebyshev as Chev
  
# array of coefficients
c = np.array([2,2,3])
print(c)
  
# shape of the array is
print("Shape of the array is : ",c.shape)
  
# dimension of the array
print("The dimension of the array is : ",c.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",c.dtype)
  
#evaluating Chebyshev series
print(Chev.chebgrid3d([1,2],[3,4],[5,6],c))

Output:

[2 2 3]
Shape of the array is :  (3,)
The dimension of the array is :  1
Datatype of our Array is :  int32
[663. 778.]

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!