- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert a polynomial to a Chebyshev series in Python
To convert a polynomial to a Chebyshev series, use the chebyshev.poly2cheb() method in Python Numpy. Convert an array representing the coefficients of a polynomial ordered from lowest degree to highest, to an array of the coefficients of the equivalent Chebyshev series, ordered from lowest to highest degree. The method returns a 1-D array containing the coefficients of the equivalent Chebyshev series. The parameter c, is a 1-D array containing the polynomial coefficients
Steps
At first, import the required library −
import numpy as np from numpy import polynomial as P
Create an array using the numpy.array() method −
c = np.array([1, 2, 3, 4, 5])
Display the array −
print("Our Array...\n",c)
Check the Dimensions −
print("\nDimensions of our Array...\n",c.ndim)
Get the Datatype −
print("\nDatatype of our Array object...\n",c.dtype)
Get the Shape −
print("\nShape of our Array object...\n",c.shape)
To convert a polynomial to a Chebyshev series, use the chebyshev.poly2cheb() method in Python Numpy −
print("\nResult (polynomial to chebyshev)...\n",P.chebyshev.poly2cheb(c))
Example
import numpy as np from numpy import polynomial as P # Create an array using the numpy.array() method c = np.array([1, 2, 3, 4, 5]) # Display the array print("Our Array...\n",c) # Check the Dimensions print("\nDimensions of our Array...\n",c.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",c.dtype) # Get the Shape print("\nShape of our Array object...\n",c.shape) # To convert a polynomial to a Chebyshev series, use the chebyshev.poly2cheb() method in Python Numpy print("\nResult (polynomial to chebyshev)...\n",P.chebyshev.poly2cheb(c))
Output
Our Array... [1 2 3 4 5] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (5,) Result (polynomial to chebyshev)... [4.375 5. 4. 1. 0.625]
Advertisements