Generate a Hermite_e series with given roots in Python

PythonNumpyServer Side ProgrammingProgramming

To generate a Hermite_e series with given roots, use the hermite_e.hermefromroots() method in Python Numpy. The method returns a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real. The parameter roots are the sequence containing the roots.

Steps

At first, import the required library −

from numpy.polynomial import hermite_e as H

Ggenerate a Hermite_e series with given roots −

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

Get the datatype −

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

Get the shape −

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

Example

from numpy.polynomial import hermite_e as H

# To generate a Hermite_e series with given roots, use the hermite_e.hermefromroots() method in Python Numpy.
print("Result...\n",H.hermefromroots((-1,0,1)))

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

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

Output

Result...
   [0. 2. 0. 1.]

Type...
float64

Shape...
(4,)
raja
Updated on 11-Mar-2022 05:21:30

Advertisements