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
Convert a Hermite_e series to a polynomial in Python
To convert a Hermite_e series to a polynomial, use the hermite_e.herme2poly() method in NumPy. This function converts an array representing the coefficients of a Hermite_e series (ordered from lowest degree to highest) to an array of coefficients of the equivalent polynomial in the standard basis.
Syntax
numpy.polynomial.hermite_e.herme2poly(c)
Parameters
The parameter c is a 1-D array containing the Hermite_e series coefficients, ordered from lowest order term to highest.
Example
Let's convert a Hermite_e series with coefficients [1, 2, 3, 4, 5] to its polynomial form ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Create an array of Hermite_e coefficients
c = np.array([1, 2, 3, 4, 5])
# Display the array
print("Hermite_e coefficients:", c)
# Check array properties
print("Dimensions:", c.ndim)
print("Datatype:", c.dtype)
print("Shape:", c.shape)
# Convert Hermite_e series to polynomial
result = H.herme2poly(c)
print("Polynomial coefficients:", result)
Hermite_e coefficients: [1 2 3 4 5] Dimensions: 1 Datatype: int64 Shape: (5,) Polynomial coefficients: [ 13. -10. -27. 4. 5.]
How It Works
The function transforms the Hermite_e series representation into standard polynomial form. The input coefficients [1, 2, 3, 4, 5] represent:
- 1 × He?(x) + 2 × He?(x) + 3 × He?(x) + 4 × He?(x) + 5 × He?(x)
The output [13, -10, -27, 4, 5] represents the polynomial:
- 13 + (-10)x + (-27)x² + 4x³ + 5x?
Practical Example
Here's a simpler example with fewer coefficients ?
import numpy as np
from numpy.polynomial import hermite_e as H
# Simple Hermite_e series: 1 + 2*He_1(x)
coeffs = np.array([1, 2])
polynomial = H.herme2poly(coeffs)
print("Hermite_e coefficients:", coeffs)
print("Polynomial coefficients:", polynomial)
print("This represents: {} + {}x".format(polynomial[0], polynomial[1]))
Hermite_e coefficients: [1 2] Polynomial coefficients: [1. 2.] This represents: 1.0 + 2.0x
Conclusion
The herme2poly() function efficiently converts Hermite_e series coefficients to standard polynomial coefficients. This transformation is useful in mathematical computations involving orthogonal polynomials and numerical analysis.
