Integrate a Chebyshev series and set the lower bound of the integral using NumPy in Python
Last Updated :
02 Jun, 2022
In this article, we will see how to integrate a Chebyshev series and set the lower bound of the integral in Python using Numpy.
To perform Chebyshev integration, NumPy provides a function called chebyshev.chebint which can be used to integrate Legendre series.
Syntax: chebyshev.chebint(c, lbnd=0, scl=1, axis=0)
Parameters:
c – Array of Chebyshev series coefficients.
lbnd – The lower bound of the integral. (Default: 0)
scl – Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1)
axis – Axis over which the integral is taken.
Example 1:
In the first example. let us consider a 1D array with 5 elements with a lbnd set to -2. Import the necessary packages as shown and pass the appropriate parameters as shown below. We are also displaying shape, dimensions, and data type of created numpy array.
Python3
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.array([11, 12, 13, 14, 15])
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.chebint(c, lbnd=-2)
# integrated chebyshev series
# with lbnd=-2
print(f'Resultant series ---> {res}')
Output:
The shape of the array is (5,)
The dimension of the array is 1D
The datatype of the array is int64
Resultant series ---> [ 3.77083333e+02 4.50000000e+00 -5.00000000e-01 -3.33333333e-01
1.75000000e+00 1.50000000e+00]
Example 2:
In the first example. let us consider a 2D array with 5 elements each with a lbnd set to -1. Import the necessary packages as shown and pass the appropriate parameters as shown below. We are also displaying the shape, dimensions, and data type of created NumPy array.
Python3
import numpy as np
from numpy.polynomial import chebyshev
# co.efficient array
c = np.array([[11, 12, 13, 14, 15], [56, 55, 44, 678, 89]])
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.chebint(c, lbnd=-1)
# integrated chebyshev series
# with lbnd=-1
print(f'Resultant series ---> {res}')
Output:
The shape of the array is (2, 5)
The dimension of the array is 2D
The datatype of the array is int64
Resultant series ---> [[ -3. -1.75 2. -155.5 -7.25]
[ 11. 12. 13. 14. 15. ]
[ 14. 13.75 11. 169.5 22.25]]
Similar Reads
Integrate Legendre series and set the lower bound of the integral using NumPy in Python In this article, we will see how to integrate a Legendre series and set the lower bound of the integral in Python using NumPy. To perform Legendre integration, NumPy provides a function called legendre.legint which can be used to integrate Legendre series. Syntax: legendre.legint(c, lbnd=0, scl=1, a
3 min read
Integrate a Chebyshev series and set the order of integration using NumPy in Python In this article, we will discuss how to integrate the Chebyshev series and set the order of integration in Python and NumPy. chebyshev.chebint method Chebyshev polynomials are significant in approximation theory because the Chebyshev nodes are used as matching points for optimizing polynomial interp
4 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
Differentiate a Chebyshev series using NumPy in Python 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 a
3 min read
Integrate a Legendre series over axis 0 using NumPy in Python In this article, we will cover how to integrate a Legendre series over axis 0 using NumPy in Python. polynomial.legendre.legint method The polynomial.legendre.legint() method from the NumPy library is used to Integrate a Legendre series over axis 0 in python.The resulting series is multiplied by scl
3 min read