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
Add one Hermite_e series to another in Python
To add one Hermite_e series to another, use the polynomial.hermite_e.hermeadd() method in NumPy. The method returns an array representing the Hermite_e series of their sum. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
Syntax
numpy.polynomial.hermite_e.hermeadd(c1, c2)
Parameters:
- c1, c2 ? 1-D arrays of Hermite_e series coefficients ordered from low to high
Returns: Array representing the sum of the two Hermite_e series
Example
Let's create two Hermite_e series and add them together ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create 1-D arrays of Hermite_e series coefficients
c1 = np.array([1, 2, 3])
c2 = np.array([3, 2, 1])
print("First Hermite_e series coefficients:", c1)
print("Second Hermite_e series coefficients:", c2)
# Add the two Hermite_e series
result = H.hermeadd(c1, c2)
print("Sum of the two series:", result)
First Hermite_e series coefficients: [1 2 3] Second Hermite_e series coefficients: [3 2 1] Sum of the two series: [4. 4. 4.]
How It Works
The hermeadd() function performs element-wise addition of the coefficients. For series c1 = [1,2,3] and c2 = [3,2,1], the result is [1+3, 2+2, 3+1] = [4, 4, 4].
Different Length Series
The function can also handle series of different lengths ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Series of different lengths
c1 = np.array([1, 2])
c2 = np.array([3, 2, 1, 4])
print("First series:", c1)
print("Second series:", c2)
result = H.hermeadd(c1, c2)
print("Sum:", result)
First series: [1 2] Second series: [3 2 1 4] Sum: [4. 4. 1. 4.]
Conclusion
Use numpy.polynomial.hermite_e.hermeadd() to add two Hermite_e series by performing element-wise addition of their coefficients. The function automatically handles series of different lengths by padding shorter series with zeros.
