Wednesday, November 27, 2024
Google search engine
HomeLanguagesIntegrate a Hermite_e series Over Axis 0 using Numpy in Python

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]]

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments