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
Selected Reading
Integrate a Hermite series and set the Integration constant in Python
To integrate a Hermite series, use the hermite.hermint() method in Python. This method integrates a Hermite series and allows you to set integration constants.
Syntax
numpy.polynomial.hermite.hermint(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Parameters
The method accepts the following 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. For m=1, can be a scalar
- lbnd ? Lower bound of the integral (default: 0)
- scl ? Scalar multiplier applied after each integration (default: 1)
- axis ? Axis over which the integral is taken (default: 0)
Basic Integration Example
Let's integrate a simple Hermite series without setting integration constants ?
import numpy as np
from numpy.polynomial import hermite as H
# Create an array of coefficients
c = np.array([1, 2, 3])
print("Original coefficients:", c)
# Integrate without setting integration constant
result = H.hermint(c)
print("Integrated series:", result)
Original coefficients: [1 2 3] Integrated series: [0. 0.5 0.5 0.5]
Setting Integration Constants
Now let's integrate the same series but set the integration constant to 3 ?
import numpy as np
from numpy.polynomial import hermite as H
# Create an array of coefficients
c = np.array([1, 2, 3])
print("Original coefficients:", c)
# Integrate with integration constant k=3
result = H.hermint(c, k=3)
print("With integration constant k=3:", result)
# Multiple integration with different constants
result_multi = H.hermint(c, m=2, k=[1, 2])
print("Double integration with k=[1, 2]:", result_multi)
Original coefficients: [1 2 3] With integration constant k=3: [3. 0.5 0.5 0.5] Double integration with k=[1, 2]: [1. 2. 0.125 0.125 0.125]
Integration Order and Bounds
You can control the order of integration and set different bounds ?
import numpy as np
from numpy.polynomial import hermite as H
c = np.array([1, 2, 3])
# Second order integration
result_order2 = H.hermint(c, m=2)
print("Second order integration:", result_order2)
# Integration with different lower bound
result_bound = H.hermint(c, lbnd=1)
print("With lbnd=1:", result_bound)
# Integration with scaling factor
result_scaled = H.hermint(c, scl=2)
print("With scaling factor scl=2:", result_scaled)
Second order integration: [0. 0. 0.125 0.125 0.125] With lbnd=1: [0. 0.5 0.5 0.5] With scaling factor scl=2: [0. 1. 1. 1.]
Conclusion
The hermite.hermint() method provides flexible integration of Hermite series with customizable integration constants. Use the k parameter to set constants, m for integration order, and scl for scaling factors.
Advertisements
