Monday, October 6, 2025
HomeLanguagesCompute the roots of a Chebyshev series with given complex roots using...

Compute the roots of a Chebyshev series with given complex roots using NumPy in Python

 In this article, we will see how to compute the roots of a Chebyshev series with given complex roots using NumPy in python.

chebyshev.chebroots() method

The chebyshev.chebroots() in python that is available in the NumPy module is used to compute the roots of a Chebyshev series with given complex roots in python. The root estimates are obtained as the eigenvalues of the given companion matrix,  Roots with a multiplicity greater than 1 will return larger errors. It will return an array of the roots of the given Chebyshev series. If all the roots are real, then the output is also real, otherwise, the output is it is complex. It will take one parameter coefficient (c) array of 1 Dimensional.

Syntax: polynomial.chebyshev.chebroots(c)

Parameter:

  • c: 1-D array of coefficients.

Return: Array of the roots of the series. real/complex.

Example 1:

In this example, we are creating a complex root – (0,1) as an array of coefficients in a 1D array and get the roots of the Chebyshev series. So the output is complex roots. and also we are displaying the datatype using dtype method and getting the shape using the shape method.

Python3




from numpy.polynomial import chebyshev
 
# consider the coefficient
j = complex(2)
 
# datatype
print(chebyshev.chebroots((-j, j)).dtype)
 
# shape
print(chebyshev.chebroots((-j, j)).shape)
 
# get the roots of chebyshev series
print(chebyshev.chebroots((-j, j)))


Output:

(2+0j)
complex128
(1,)
[1.+0.j]

Example 2:

In this example, we are creating a complex root – (2,5)  as an array of coefficients in a 1D array and get the roots of the Chebyshev series. So the output is complex roots. and also we are displaying the datatype using dtype method and getting the shape using the shape method.

Python3




from numpy.polynomial import chebyshev
 
# consider the coefficient
j = complex(1,3)
print(j)
 
# datatype
print(chebyshev.chebroots((-j, j)).dtype)
 
# shape
print(chebyshev.chebroots((-j, j)).shape)
 
# get the roots of chebyshev series
print(chebyshev.chebroots((-j, j)))


Output:

(1+3j)
complex128
(1,)
[1.+0.j]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32338 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6707 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6825 POSTS0 COMMENTS
Ted Musemwa
7089 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6780 POSTS0 COMMENTS