Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Integrate a Hermite series over axis 0 in Python
To integrate a Hermite series over a specific axis, use the hermite.hermint() method in Python. This function performs integration along the specified axis of a multidimensional array of Hermite series coefficients.
Parameters
The hermint() method accepts several parameters ?
- c ? Array of Hermite series coefficients. For multidimensional arrays, different axes correspond to different variables
- m ? Order of integration (must be positive, default: 1)
- k ? Integration constant(s). Default is empty list (all constants set to zero)
- lbnd ? Lower bound of the integral (default: 0)
- scl ? Scaling factor applied after each integration (default: 1)
- axis ? Axis over which the integral is taken
Example
Let's integrate a Hermite series over axis 0 using a 2D coefficient array ?
import numpy as np
from numpy.polynomial import hermite as H
# Create a multidimensional array of coefficients
c = np.arange(4).reshape(2, 2)
# Display the array
print("Our Array...")
print(c)
# Check the dimensions and properties
print("\nDimensions of our Array...")
print(c.ndim)
print("\nDatatype of our Array object...")
print(c.dtype)
print("\nShape of our Array object...")
print(c.shape)
# Integrate the Hermite series over axis 0
result = H.hermint(c, axis=0)
print("\nResult after integration over axis 0...")
print(result)
Our Array... [[0 1] [2 3]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result after integration over axis 0... [[1. 1.5 ] [0. 0.5 ] [0.5 0.75]]
How Integration Works
When integrating over axis 0, the function treats each column as a separate Hermite series. The integration increases the degree of the polynomial, which is why the result array has shape (3, 2) instead of the original (2, 2).
Integration with Custom Parameters
You can specify different integration parameters for more control ?
import numpy as np
from numpy.polynomial import hermite as H
# Create coefficient array
c = np.array([[1, 2], [3, 4]])
# Integration with custom parameters
result_custom = H.hermint(c, m=1, k=[1, 2], lbnd=1, scl=2, axis=0)
print("Custom integration result:")
print(result_custom)
Custom integration result: [[ 3. 6. ] [ 2. 4. ] [ 3. 4. ]]
Conclusion
The hermite.hermint() method efficiently integrates Hermite series over specified axes. Integration increases the polynomial degree and allows customization through parameters like integration constants and scaling factors.
