# Compute the roots of a Hermite_e series in Python

PythonNumpyServer Side ProgrammingProgramming

To compute the roots of a Hermite_e 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 out 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.

## Steps

At first, import the required library −

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

To compute the roots of a Hermite_e series, use the hermite.hermroots() method in Python Numpy −

print("Result...\n",H.hermeroots((-1, 0, 1)))

Get the datatype −

print("\nType...\n",H.hermeroots((-1, 0, 1)).dtype)

Get the shape −

print("\nShape...\n",H.hermeroots((-1, 0, 1)).shape)


## Example

from numpy.polynomial import hermite_e as H

# To compute the roots of a Hermite_e 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 out is also real, otherwise it is complex..

# The parameter, c is a 1-D array of coefficients.
print("Result...\n",H.hermeroots((-1, 0, 1)))

# Get the datatype
print("\nType...\n",H.hermeroots((-1, 0, 1)).dtype)

# Get the shape
print("\nShape...\n",H.hermeroots((-1, 0, 1)).shape)

## Output

Result...
[-1.41421356 1.41421356]

Type...
float64

Shape...
(2,)