Compute the roots of a Hermite series with given complex roots in Python

To compute the roots of a Hermite series, use the hermite.hermroots() method in Python NumPy. The method returns an array of the roots of the series. If all the roots are real, then the output is also real, otherwise it is complex.

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.hermroots(c)

Parameters

c: 1-D array of coefficients representing the Hermite series

Returns

Array of the roots of the series. The dtype will be complex if any roots are complex, otherwise real.

Example

Let's compute the roots of a Hermite series with complex coefficients ?

from numpy.polynomial import hermite as H

# Define complex coefficients
j = complex(0, 1)
coefficients = (-j, j)

# Compute the roots of the Hermite series
roots = H.hermroots(coefficients)

print("Coefficients:", coefficients)
print("Roots:", roots)
print("Data type:", roots.dtype)
print("Shape:", roots.shape)
Coefficients: ((-0-1j), 1j)
Roots: [0.5+0.j]
Data type: complex128
Shape: (1,)

Real Coefficients Example

Let's see how the method works with real coefficients ?

from numpy.polynomial import hermite as H
import numpy as np

# Hermite series with real coefficients: 1 + 2x + 3x²
real_coefficients = [1, 2, 3]
real_roots = H.hermroots(real_coefficients)

print("Real coefficients:", real_coefficients)
print("Roots:", real_roots)
print("Data type:", real_roots.dtype)
Real coefficients: [1, 2, 3]
Roots: [-0.81649658+0.j -0.18350342+0.j]
Data type: complex128

How It Works

The hermroots() function constructs the companion matrix for the Hermite series and computes its eigenvalues, which correspond to the roots. For a Hermite series represented as:

p(x) = c[0]*H?(x) + c[1]*H?(x) + ... + c[n]*H?(x)

where H?, H?, ..., H? are Hermite polynomials, the function finds the values of x where p(x) = 0.

Conclusion

The hermite.hermroots() method efficiently computes roots of Hermite series using eigenvalue decomposition. It handles both real and complex coefficients, returning complex output when necessary to preserve accuracy.

Updated on: 2026-03-26T20:32:49+05:30

258 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements