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
Raise a Hermite series to a power in Python
To raise a Hermite series to a power, use the polynomial.hermite.hermpow() method in NumPy. This method returns a Hermite series raised to the specified power. The argument c is a sequence of coefficients ordered from low to high, where [1,2,3] represents the series P_0 + 2*P_1 + 3*P_2.
Syntax
numpy.polynomial.hermite.hermpow(c, pow, maxpower=16)
Parameters
The function accepts the following parameters:
- c: 1-D array of Hermite series coefficients ordered from low to high
- pow: Power to which the series will be raised
- maxpower: Maximum power allowed (default is 16) to limit series growth
Example
Let's create a Hermite series and raise it to the power of 3 ?
import numpy as np
from numpy.polynomial import hermite as H
# Create 1-D array of Hermite series coefficients
coefficients = np.array([1, 2, 3])
# Display the coefficient array
print("Coefficient Array:")
print(coefficients)
# Check array properties
print("\nDimensions:", coefficients.ndim)
print("Datatype:", coefficients.dtype)
print("Shape:", coefficients.shape)
# Raise Hermite series to power of 3
result = H.hermpow(coefficients, 3)
print("\nHermite series raised to power 3:")
print(result)
Coefficient Array: [1 2 3] Dimensions: 1 Datatype: int64 Shape: (3,) Hermite series raised to power 3: [2257. 2358. 3837. 908. 711. 54. 27.]
Different Powers
Let's see how the result changes with different power values ?
import numpy as np
from numpy.polynomial import hermite as H
coefficients = np.array([1, 2, 3])
# Test different powers
for power in [1, 2, 3]:
result = H.hermpow(coefficients, power)
print(f"Power {power}: {result}")
Power 1: [1. 2. 3.] Power 2: [33. 44. 39. 18. 9.] Power 3: [2257. 2358. 3837. 908. 711. 54. 27.]
How It Works
The hermpow() function performs polynomial multiplication in the Hermite basis. When raising to power n, it multiplies the series by itself n times, following Hermite polynomial arithmetic rules.
Conclusion
The hermpow() method efficiently raises Hermite series to any power while maintaining proper coefficient ordering. Use the maxpower parameter to control computational complexity for large powers.
