Python NumPy – Convert a Polynomial to a Chebyshev series
The polynomial.chebyshev.poly2cheb() method from the NumPy library converts a polynomial to a Chebyshev series in python. This method is used to Convert an array of coefficients reflecting a polynomial’s coefficients (arranged from lowest to highest degree to an array of coefficients expressing the corresponding Chebyshev series, arranged from lowest to the highest degree.
- pol: array like object.The polynomial coefficients are stored in a 1-D array.
- c : ndarray. The coefficients of the analogous Chebyshev series are stored in a one-dimensional array.
In this example, we created two arrays of numbers that represent a polynomial using the np.array() method. coefficients should go from low to high The shape of the array is defined by the .shape attribute and the dimension of the array is defined by .ndim, the datatype of the array is returned by the .dtype attribute. The chebyshev.poly2cheb() method convert polynomial to Chebyshev series.
[11 22 33] Shape of the array1 is : (3,) The dimension of the array1 is : 1 Datatype of our Array is : int64 polynomial to chebyshev series : [27.5 22. 16.5]
We can also use the polynomial.Polynomial.convert() method to convert a polynomial to Chebyshev series.
polynomial to chebyshev series : cheb([ 6.5625 14.6328125 9.3125 7.5625 3.375 2.34375
0.6875 0.42578125 0.0625 0.03515625])