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_e series and set the order of integration in Python
To integrate a Hermite_e series, use the hermite_e.hermeint() method in Python. This function performs polynomial integration on Hermite_e series coefficients with customizable integration order and constants.
Syntax
numpy.polynomial.hermite_e.hermeint(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Parameters
The function accepts the following parameters:
- c - Array of Hermite_e series coefficients
- m - Order of integration (must be positive, default: 1)
- k - Integration constant(s) (default: [])
- 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)
Example
Let's integrate a Hermite_e series with different integration orders ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of coefficients
c = np.array([1, 2, 3])
# Display the array
print("Coefficients:", c)
print("Shape:", c.shape)
# Integrate with order m = 1 (default)
result1 = H.hermeint(c)
print("\nIntegration order 1:")
print(result1)
# Integrate with order m = 2
result2 = H.hermeint(c, m=2)
print("\nIntegration order 2:")
print(result2)
# Integrate with order m = 3
result3 = H.hermeint(c, m=3)
print("\nIntegration order 3:")
print(result3)
Coefficients: [1 2 3] Shape: (3,) Integration order 1: [0. 1. 1. 1.] Integration order 2: [0. 0. 0.5 0.33333333 0.25 ] Integration order 3: [ 0. 0.25 -0.25 0.5 0.16666667 0.08333333 0.05 ]
Integration with Constants
You can specify integration constants using the k parameter ?
import numpy as np
from numpy.polynomial import hermite_e as H
c = np.array([1, 2, 3])
# Integration with constant k = 5
result_with_constant = H.hermeint(c, m=1, k=[5])
print("With integration constant k=5:")
print(result_with_constant)
# Integration with multiple constants for higher order
result_multi_const = H.hermeint(c, m=2, k=[2, 3])
print("\nWith multiple constants [2, 3]:")
print(result_multi_const)
With integration constant k=5: [5. 1. 1. 1.] With multiple constants [2, 3]: [2. 3. 0.5 0.33333333 0.25 ]
How It Works
The integration process follows these steps:
- Each coefficient is integrated according to Hermite_e polynomial rules
- The result is multiplied by the scaling factor
scl - Integration constants are added based on the lower bound
lbnd - Higher order integration repeats this process
mtimes
Conclusion
The hermeint() function provides flexible integration of Hermite_e series with customizable order and constants. Higher integration orders increase the polynomial degree and modify the coefficient structure accordingly.
Advertisements
