Open In App

Python | Numpy np.chebfromroots() method

With the help of np.chebfromroots() method, we can get the chebyshev series with the roots passed as parameter in np.chebfromroots() method.

Syntax : np.chebfromroots(roots)
Return : Return the chebyshev series.



Example #1 :
In this example we can see that by using np.chebfromroots() method, we are able to get the chebyshev series that is generated by roots those are passed by parameter.




# import numpy
import numpy as np
import numpy.polynomial.chebyshev as cheb
  
# using np.chebfromroots() method
gfg = cheb.chebfromroots((2, 4, 8, 1))
  
print(gfg)

Output :

[9.9375e+01 -1.3125e+02 3.5500e+01 -3.7500e+00 1.2500e-01]



Example #2 :




# import numpy
import numpy as np
import numpy.polynomial.chebyshev as cheb
  
# using np.chebfromroots() method
gfg = cheb.chebfromroots((-3, 4, -5, 1, 10))
  
print(gfg)

Output :

[-5.19125e+02 4.52375e+02 8.00000e+01 -1.24375e+01 -8.75000e-01 6.25000e-02]

Article Tags :