Integrate a Hermite_e series Over Axis 0 using Numpy in Python

In this article, we will cover how to integrate a Hermite_e series over axis 0 using NumPy in Python.

NumPy e.hermeint() methodĀ 

We useĀ the hermite e.hermeint() function present in the NumPy module of python to integrate a Hermite e series. The first parameter ā€˜arr’ is an array of coefficients from the Hermite e series. If ā€˜arr’ is multi-dimensional, the various axes correspond to various variables, with the degree in each axis being determined by the associated index.

The second parameter ā€˜m’ is theĀ integration’sĀ order and itĀ should be positive. The integration constant(s)Ā k is the third parameter. The first value in the list is the value of the first integral at ā€˜lbnd’ (the lower bound of the integral which is an optional parameter having a default value zero(0)), the second value is the value of theĀ second integral, and so on.Ā when the value of m == 1, we can use a single scalar rather than using a list.Ā 

ā€˜lbnd’ is the fourthĀ parameter andĀ is the lower bound of the integral Ā (The default value is 0). ā€˜scl’ isĀ the fifth parameter and it’s a scalar. Before adding the integration constant, the result of each integration is multiplied by ā€˜scl’ (the default is 1). The axis parameter, which is the sixth parameter, is an axis across which the integral is calculated.

Parameters :Ā 

  • arr : (an array_like structure containing Hermite_e series coefficients)
  • m : integer, optional parameter
  • k : {[], list, scalar}, optional parameter
  • lbnd : scalar, optional parameter
  • scl : scalar, optional parameter
  • axis : integer, optional parameter

Returns : ndarray

Raises : ValueError (if m < 0, len(k) > m, np.ndim(lbnd) != 0, or np.ndim(scl) != 0)

Example 1 :

Importing NumPy and Ā Hermite_e libraries, create a multidimensional array of coefficients and then use hermite_e.hermeint()Ā 

Python3




# import hermite_e libraries
from numpy.polynomial import hermite_e as h
Ā 
# create a multidimensional array
# 'arr' of coefficients
arr = [[0, 1, 2],[3, 4, 5]]
Ā 
# integrate a Hermite_e series using
# hermite_e.hermeint() function
print(h.hermeint(arr, m=2, k=[1, 2], lbnd=-1, axis=0))


Output :

[[2.         2.66666667 3.33333333]
 [1.         2.         3.        ]
 [0.         0.5        1.        ]
 [0.5        0.66666667 0.83333333]]

Example 2:Ā 

Python3




# import numpy and hermite_e libraries
import numpy as np
from numpy.polynomial import hermite_e
Ā 
# create a multidimensional array
# 'arr' of coefficients
arr = np.arange(6).reshape(2,3)
Ā 
# integrate a Hermite_e series using
# hermite_e.hermeint() function
print(hermite_e.hermeint(arr, axis = 0))


Output :

[[1.5 2.  2.5]
 [0.  1.  2. ]
 [1.5 2.  2.5]]

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button