Integrate a Chebyshev series over axis 0 in Python

PythonNumpyServer Side ProgrammingProgramming

To Integrate a Chebyshev series, use the chebyshev.chebint() method in Python. Returns the Chebyshev series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added. The 1st parameter, c is an array of Chebyshev series coefficients. If c is multidimensional the different axis correspond to different variables with the degree in each axis given by the corresponding index.

The 2nd parameter, m is an order of integration, must be positive. (Default: 1). The 3rd parameter, k is an Integration constant(s). The value of the first integral at zero is the first value in the list, the value of the second integral at zero is the second value, etc. If k == [] (the default), all constants are set to zero. If m == 1, a single scalar can be given instead of a list.

The 4th parameter, lbnd is the lower bound of the integral. (Default: 0). The 5th parameter, scl. Following each integration the result is multiplied by scl before the integration constant is added. (Default: 1). The 6th parameter, axis is an axis over which the integral is taken. (Default: 0).

Steps

At first, import the required library −

import numpy as np
from numpy.polynomial import chebyshev as C

Create a multidimensional array of Chebyshev series coefficients −

c = np.arange(4).reshape(2,2)

Display the coefficient array −

print("Our coefficient 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 Integrate a Chebyshev series, use the chebyshev.chebint() method in Python. Returns the Chebyshev series coefficients c integrated m times from lbnd along axis. At each iteration the resulting series is multiplied by scl and an integration constant, k, is added −

print("\nResult...\n",C.chebint(c, axis = 0))

Example

import numpy as np
from numpy.polynomial import chebyshev as C

# Create an multidimensional array of Chebyshev series coefficients
c = np.arange(4).reshape(2,2)

# Display the coefficient array
print("Our coefficient 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 Integrate a Chebyshev series, use the chebyshev.chebint() method in Python
print("\nResult...\n",C.chebint(c, axis = 0))

Output

Our coefficient Array...
   [[0 1]
   [2 3]]

Dimensions of our Array...
2

Datatype of our Array object...
int64

Shape of our Array object...
(2, 2)

Result...
   [[0.5 0.75]
   [0. 1. ]
   [0.5 0.75]]
raja
Updated on 03-Mar-2022 05:50:36

Advertisements