Open In App

Multiply one Chebyshev series to another in Python

Last Updated : 22 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to multiply one Chebyshev series with another in Python using NumPy.

Example

Input: First array: [6 7 5] 

Second array: [4 5 6]

Output: [56.5 91.5 73.5 33.5 15. ]

Explanation: an array of Chebyshev series coefficients representing their product.

chebyshev.chebmul method

The Chebyshev polynomials in mathematics are two sequences of polynomials related to the sine and cosine trigonometric functions. In python, the Chebyshev module provides functions like chebmul() to multiply one Chebyshev series with another where the first parameter is the Chebyshev series coefficient array and the second is the Chebyshev series coefficient array and returns an array of Chebyshev series coefficients representing their product. 

Syntax: chebyshev.chebmul(a1, a2)

Parameter:

  • a1, a2: 1-D arrays of Chebyshev series.

Return: an array of Chebyshev series coefficients representing their product.

Example 1:

In this example, we will create two one-dimensional Chebyshev series coefficient arrays with 3 elements each and multiply two Chebyshev series with the help of chebyshev.chebmul.

Python3




# import the numpy module
import numpy
  
# import chebyshev
from numpy.polynomial import chebyshev 
  
# create array of coefficients with 
# 6 elements each
first = numpy.array([6, 7, 5])
second = numpy.array([4, 5, 6])
  
# Display the coefficient arrays
print(f"First array: {first} \nSecond array: {second}")
  
# get the shape, # get the dimensions
print(f"\nShape of First array: {first.shape} Dimension: {first.ndim}")
print(f"Shape of second array: {second.shape} Dimension: {second.ndim}")
  
  
# multiply two chebyshev series.
print("Product of two chebyshev series: ",chebyshev.chebmul(first,second))


Output:

First array: [6 7 5] 
Second array: [4 5 6]

Shape of First array: (3,) Dimension: 1
Shape of second array: (3,) Dimension: 1
Product of two chebyshev series:  [56.5 91.5 73.5 33.5 15. ]

Example 2:

In this example, we will create two one dimensional Chebyshev series coefficient arrays with 2 elements each and multiply two Chebyshev series with the help of chebyshev.chebmul.

Python3




# import the numpy module
import numpy
  
# import chebyshev
from numpy.polynomial import chebyshev 
  
# create array of coefficients with 2 elements each
first = numpy.array([34,56])
second = numpy.array([94,46])
  
# Display the coefficient arrays
print(f"First array: {first} \nSecond array: {second}")
  
# get the shape, # get the dimensions
print(f"\nShape of First array: {first.shape} Dimension: {first.ndim}")
print(f"Shape of second array: {second.shape} Dimension: {second.ndim}")
  
# multiply two chebyshev series.
print("Product of two chebyshev series: ", chebyshev.chebmul(first,second))


Output:

First array: [34 56] 
Second array: [94 46]

Shape of First array: (2,) Dimension: 1
Shape of second array: (2,) Dimension: 1
Product of two chebyshev series:  [4484. 6828. 1288.]


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads