Generate Chebyshev series with given complex roots using NumPy in Python
In this article, we will cover how to generate the Chebyshev series with given complex roots in Python using NumPy.
Input: (4+5j) Output: [9.5-40.j 0. +0.j 0.5 +0.j] Explanation: An array of Chebyshev series.
In python, the Chebyshev module provides many functions like chebfromroots to perform arithmetic, and calculus operations on the Chebyshev series. It is one of the functions provided by the Chebyshev class that returns an array of coefficients. This method is used to generate the Chebyshev series which is available in the NumPy module in python. Below is the syntax of the chebfromroots method.
- If all roots are real then the output will be a real array,
- If any of the roots are complex, the output is a complex array.
Syntax: chebyshev.chebfromroots((-my_value, my_value))
- my_value: is the complex number.
Return: 1-D array of coefficients.
In this example, we will create a complex number using a complex function, which will return an array of Chebyshev roots.
Complex value: (4+5j) chebyshev roots: [9.5-40.j 0. +0.j 0.5 +0.j]
In this example, we will create a complex variable -> 45+4j and generate Chebyshev roots. We can also get the shape and dimensions of the resultant array using dim and shape functions.
Complex value: (45+4j)
chebyshev roots: [-2.0085e+03-360.j 0.0000e+00 +0.j 5.0000e-01 +0.j]