Convert a Chebyshev series to a polynomial in Python

To convert a Chebyshev series to a polynomial, use the chebyshev.cheb2poly() method in Python NumPy. This function converts an array representing the coefficients of a Chebyshev series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest degree.

The method returns a 1-D array containing the coefficients of the equivalent polynomial ordered from lowest order term to highest. The parameter c is a 1-D array containing the Chebyshev series coefficients, ordered from lowest order term to highest.

Syntax

numpy.polynomial.chebyshev.cheb2poly(c)

Parameters

c: array_like − 1-D array containing the Chebyshev series coefficients, ordered from lowest order term to highest.

Return Value

Returns a 1-D array containing the coefficients of the equivalent polynomial ordered from lowest order term to highest.

Example

Let's see how to convert a Chebyshev series to a polynomial ?

import numpy as np
from numpy import polynomial as P

# Create an array representing Chebyshev series coefficients
coefficients = np.array([1, 2, 3, 4, 5])

# Display the array
print("Our Array...\n", coefficients)

# Check the Dimensions
print("\nDimensions of our Array...\n", coefficients.ndim)

# Get the Datatype
print("\nDatatype of our Array object...\n", coefficients.dtype)

# Get the Shape
print("\nShape of our Array object...\n", coefficients.shape)

# Convert Chebyshev series to polynomial
result = P.chebyshev.cheb2poly(coefficients)
print("\nResult (chebyshev to polynomial)...\n", result)
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 (chebyshev to polynomial)...
 [ 3. -10. -34.  16.  40.]

How It Works

The Chebyshev polynomials form an orthogonal basis, and this function converts from the Chebyshev basis to the standard monomial basis. Each Chebyshev polynomial can be expressed as a linear combination of standard polynomial terms, and cheb2poly() performs this transformation.

Another Example with Different Coefficients

import numpy as np
from numpy import polynomial as P

# Simple Chebyshev series with fewer coefficients
simple_coeffs = np.array([1, 0, 1])
print("Chebyshev coefficients:", simple_coeffs)

# Convert to polynomial
poly_coeffs = P.chebyshev.cheb2poly(simple_coeffs)
print("Polynomial coefficients:", poly_coeffs)
Chebyshev coefficients: [1 0 1]
Polynomial coefficients: [ 0.  0.  2.]

Conclusion

The cheb2poly() function is essential for converting Chebyshev series representations to standard polynomial form. This conversion is useful in numerical analysis and computational mathematics where different polynomial bases are required for specific applications.

Updated on: 2026-03-26T19:53:25+05:30

380 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements