Differentiate a Chebyshev series using NumPy in Python
Last Updated :
06 May, 2022
In this article, we will cover how to integrate a Chebyshev series and set the integration constant in Python using NumPy.
chebyshev.chebder method
The Chebyshev series has polynomials with the largest possible leading coefficient, whose absolute value on the interval [−1, 1] is bounded by 1. They are also the "extremal" polynomials. Chebyshev polynomials are significant in approximation theory because the roots of Tn(x), which are also called Chebyshev nodes, are used as matching points for optimizing polynomial interpolation. The resulting interpolation polynomial minimizes the problem of Runge's phenomenon and provides an approximation that is close to the best polynomial approximation to a continuous function under the maximum norm, also called the "minimax" criterion.
In python, to perform Chebyshev differentiation, NumPy provides a function called chebyshev.chebder which can be used to integrate the Chebyshev series. This function returns the Chebyshev series coefficients c differentiated m times along the axis.
Syntax: chebyshev.chebder(c, m=1, scl=1, axis=0)
Parameters:
- c - an array of Chebyshev series coefficients
- m - no of derivatives taken, must be non-negative
- scl - scaler (linear) value, Each differentiation is multiplied by scl.
- axis - Axis over which the derivative is taken. default - 0
Return: Chebyshev series
Example 1:
In the first example. let us consider a 1D array with a first-order derivative and 1 as a scaling constant. Import the necessary packages as shown and pass the appropriate parameters as shown below.
Python3
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 11])
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
res = chebyshev.chebder(c, m=1, scl=1)
# differentiated chebyshev series with
# first order derivative and scale 1
print(f'Resultant series ---> {res}')
Output:
OutputExample 2:
In the second example. let us consider a 1D array with a second-order derivative and 5 as a scaling constant. Import the necessary packages as shown and pass the appropriate parameters as shown below.
Python3
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 11])
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
res = chebyshev.chebder(c, m=2, scl=5)
# differentiated chebyshev series with
# second order derivative and scale 5
print(f'Resultant series ---> {res}')
Output:
OutputExample 3:
In the third example. let us consider a 1D array with a third-order derivative and 7 as a scaling constant. Import the necessary packages as shown and pass the appropriate parameters as shown below.
Python3
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 11])
print(f'The shape of the array is {c.shape}')
print(f'The dimension of the array is {c.ndim}D')
print(f'The datatype of the array is {c.dtype}')
res = chebyshev.chebder(c, m=3, scl=7)
# differentiated chebyshev series with
# third order derivative and scale 7
print(f'Resultant series ---> {res}')
Output:
Output
Similar Reads
Differentiate a Legendre series using NumPy in Python In this article, we will cover how to differentiate a Legendre series in Python using NumPy. legendre.legder method In python, the Legendre module provides many functions like legder to perform arithmetic, and calculus operations on the Legendre series. It is one of the functions provided by the Leg
3 min read
Compute the roots of a Chebyshev series using NumPy in Python This article will discuss how to compute the roots of a Chebyshev series in NumPy using Python. Chebyshev polynomials are important in approximation theory these are never formally generated. Only the coefficients are required for all calculations. If we want to compute the roots of a polynomial we
2 min read
Divide one Hermite series by another in Python using NumPy In this article, we are going to see how to divide one Hermite series by another in Python using NumPy. The numpy hermdiv() method helps us divide one Hermite series by another. The quotient and remainder of two Hermite series, c1 / c2, are returned. The arguments are a series of coefficients from l
3 min read
Raise Chebyshev series to a power using NumPy in Python In this article, we will cover how to raise a Chebyshev series to power in Python using NumPy. polynomial.chebyshev.chebpow method The Chebyshev polynomials are like the other classical orthogonal polynomials which can be defined from a variety of starting locations. Â Here, we will see how to raise
3 min read
Differentiate a Chebyshev series with multidimensional coefficients in Python In this article, we will cover how to differentiate the Chebyshev series with multidimensional coefficients in Python using NumPy. Example Input: [[1 2 3 4 5] Â [3 4 2 6 7]] Output: [[3. 4. 2. 6. 7.]] Explanation: Chebyshev series of the derivative. chebyshev.chebder method To evaluate a Chebyshev se
3 min read
Differentiate a Legendre series and set the derivatives using NumPy in Python In this article, we will cover how to differentiate a Legendre series and set the derivatives using NumPy in Python. numpy.polynomial.legendre.legder The numpy.polynomial.legendre.legder() method from the NumPy library is used to differentiate a Legendre series and set the derivatives in Python. The
3 min read