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
Compute the roots of a Hermite_e series with given complex roots in Python
To compute the roots of a Hermite_e series, use the hermite_e.hermeroots() method in Python NumPy. The method returns an array of the roots of the series. If all the roots are real, then output is also real, otherwise it is complex.
The parameter c is a 1-D array of coefficients. The root estimates are obtained as the eigenvalues of the companion matrix. Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton's method.
Syntax
numpy.polynomial.hermite_e.hermeroots(c)
Parameters:
-
c: 1-D array of coefficients
Returns: Array of roots of the Hermite_e series
Example
First, import the required library ?
from numpy.polynomial import hermite_e as H
# Define complex coefficients
j = complex(0, 1)
print("Coefficients:", (-j, j))
# Compute the roots of a Hermite_e series
roots = H.hermeroots((-j, j))
print("Result...\n", roots)
# Get the datatype
print("\nType...\n", roots.dtype)
# Get the shape
print("\nShape...\n", roots.shape)
Coefficients: (-1j, 1j) Result... [1.+0.j] Type... complex128 Shape... (1,)
Example with Real Coefficients
Let's see what happens with real coefficients ?
from numpy.polynomial import hermite_e as H
# Real coefficients
coefficients = [1, 2, 1]
roots = H.hermeroots(coefficients)
print("Coefficients:", coefficients)
print("Roots:", roots)
print("Data type:", roots.dtype)
Coefficients: [1, 2, 1] Roots: [-2.41421356 -0.41421356] Data type: float64
Key Points
- Returns complex array when coefficients are complex
- Returns real array when all roots are real
- Uses companion matrix eigenvalues for root computation
- Numerical errors increase for roots far from origin
Conclusion
The hermite_e.hermeroots() method efficiently computes roots of Hermite_e polynomial series. It automatically handles both real and complex coefficients, returning appropriate data types based on the nature of the roots.
