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 in Python
To integrate a Hermite series in Python, use the hermite.hermint() method from NumPy. This function performs polynomial integration on Hermite series coefficients and returns the integrated coefficients.
Syntax
numpy.polynomial.hermite.hermint(c, m=1, k=[], lbnd=0, scl=1, axis=0)
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). If empty list (default), all constants are zero
- lbnd ? Lower bound of the integral (default: 0)
- scl ? Scalar multiplier applied after each integration (default: 1)
- axis ? Axis over which integration is performed (default: 0)
Example
Let's create a simple Hermite series and integrate it ?
import numpy as np
from numpy.polynomial import hermite as H
# Create an array of coefficients
c = np.array([1, 2, 3])
# Display the array
print("Our Array...")
print(c)
# Check the Dimensions
print("\nDimensions of our Array...")
print(c.ndim)
# Get the Datatype
print("\nDatatype of our Array object...")
print(c.dtype)
# Get the Shape
print("\nShape of our Array object...")
print(c.shape)
# To integrate a Hermite series, use the hermite.hermint() method
print("\nResult...")
print(H.hermint(c))
Our Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result... [1. 0.5 0.5 0.5]
Integration with Different Parameters
You can also specify integration order and constants ?
import numpy as np
from numpy.polynomial import hermite as H
# Original coefficients
c = np.array([1, 2, 3])
# Integrate twice (m=2) with integration constant k=5
result = H.hermint(c, m=2, k=5)
print("Integration with m=2, k=5:")
print(result)
# Integration with scaling factor
result_scaled = H.hermint(c, scl=2)
print("\nIntegration with scaling factor scl=2:")
print(result_scaled)
Integration with m=2, k=5: [5. 1. 0.25 0.125 0.125] Integration with scaling factor scl=2: [2. 1. 1. 1.]
How It Works
The hermint() function integrates each term of the Hermite series. For a coefficient array [1, 2, 3] representing the series 1?H?(x) + 2?H?(x) + 3?H?(x), integration produces a new series with an additional term and modified coefficients.
Conclusion
The hermite.hermint() method provides a convenient way to integrate Hermite series in Python. Use the m parameter for multiple integrations and k for integration constants.
