# Divide one Chebyshev series by another in Python

• Last Updated : 21 Apr, 2022

In this article, we will be looking at a method to divide one Chebyshev series by another in Python.

A linear combination of Chebyshev polynomials is known as a Chebyshev series. Chebyshev polynomials are never formally generated. Only the coefficients are required for all calculations. In this article let’s see how to divide one Chebyshev series by another. Numpy library provides us numpy.polynomial.chebyshev.chebdiv() method which is used to divide two Chebyshev series.

Syntax: numpy.polynomial.chebyshev.chebdiv(c1, c2)

Parameters:

• c1: array like object. Chebyshev series coefficients are arranged from low to high in a 1-D array.
• c2: array like object. The quotient and remainder are represented by Chebyshev series coefficients.

Return:

After division, return an array.

### Example 1:

We import the NumPy package. we create two arrays, c1 is a Chebyshev series coefficients are arranged from low to high in a 1-D array. c2 is the quotient and the remainder are represented by Chebyshev series coefficients. Chev.chebdiv() is the function used to divide two Chebyshev series. The shape of the array is found by .shape attribute, the dimension of the array is found by .ndim attribute, and the data type of the array is .dtype attribute.

## Python3

 `# import packages``import` `numpy as np``from` `numpy.polynomial ``import` `chebyshev as Chev`` ` `# Creating arrays of coefficients``array ``=` `np.array([``3``, ``1``, ``4``])``array2 ``=` `np.array([``5``, ``7``, ``9``])``print``(array)``print``(array2)`` ` `# shape of the arrays``print``(``"Shape of the array1 is : "``, array.shape)``print``(``"Shape of the array2 is : "``, array2.shape)`` ` `# dimensions of the array``print``(``"The dimension of the array1 is : "``, array.ndim)``print``(``"The dimension of the array2 is : "``, array2.ndim)`` ` `# Datatype of the arrays``print``(``"Datatype of our Array1 is : "``, array.dtype)``print``(``"Datatype of our Array2 is : "``, array2.dtype)`` ` `# dividing Chebyshev series``print``(Chev.chebdiv(array, array2))`

Output:

```[3 1 4]
[5 7 9]
Shape of the array1 is :  (3,)
Shape of the array2 is :  (3,)
The dimension of the array1 is :  1
The dimension of the array2 is :  1
Datatype of our Array1 is :  int64
Datatype of our Array2 is :  int64
(array([0.44444444]), array([ 0.77777778, -2.11111111]))```

### Example 2:

In this example, neither quotient nor remainder is “intuitive” and we are further dividing the Chebyshev series by another in python.

## Python3

 `# import packages``import` `numpy as np``from` `numpy.polynomial ``import` `chebyshev as Chev`` ` `# Creating arrays of coefficients``# neither quotient and remainder "intuitive"``array ``=` `np.array([``11``, ``22``, ``33``])``array2 ``=` `np.array([``1``, ``11``, ``22``, ``33``])``print``(array)``print``(array2)`` ` `# shape of the arrays``print``(``"Shape of the array1 is : "``, array.shape)``print``(``"Shape of the array2 is : "``, array2.shape)`` ` `# dimensions of the array``print``(``"The dimension of the array1 is : "``, array.ndim)``print``(``"The dimension of the array2 is : "``, array2.ndim)`` ` `# Datatype of the arrays``print``(``"Datatype of our Array1 is : "``, array.dtype)``print``(``"Datatype of our Array2 is : "``, array2.dtype)`` ` `# dividing Chebyshev series``print``(Chev.chebdiv(array2, array))`

Output:

```[11 22 33]
[ 1 11 22 33]
Shape of the array1 is :  (3,)
Shape of the array2 is :  (4,)
The dimension of the array1 is :  1
The dimension of the array2 is :  1
Datatype of our Array1 is :  int64
Datatype of our Array2 is :  int64
(array([0., 2.]), array([-21., -44.]))```

My Personal Notes arrow_drop_up