Generate a Hermite_e series with given roots using NumPy in Python

In this article, we will cover how to raise a Hermite_e series to power in Python using NumPy.
hermite_e.hermefromroots() function
We use the hermite_e.hermefromroots() function present in the NumPy module of python to construct a Hermite_e series with the given roots. A 1-D array of coefficients is returned by the following function. we will get a real array if all of the roots are real; if any of the roots are complex than we will get a complex array even if all of the coefficients in the result are real.
Syntax: numpy.polynomial.hermite_e.hermefromroots(roots)
Parameters:
- Sequence containing the roots.
Returns : ndarray ,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
Steps to generate the Hermite_e series with given roots :
Step 1: Importing the hermite_e library.
from numpy.polynomial import hermite_e
Step 2: Create a 1-dimensional array of roots.
arr = [1,2,0]
Step 3: Finally generate a Hermite_e series with the array of roots.
print(hermite_e.hermefromroots(arr))
Example 1:
In this example, we are creating a simple array to return a Hermite_e series with the given roots using hermefromroots.
Python3
# import hermite_e library from numpy.polynomial import hermite_e # create an array 'arr' of roots arr = [1, 0, -2] # generate a Hermite_e series with given # roots using hermefromroots() function print(hermite_e.hermefromroots(arr)) |
Output:
[1. 1. 1. 1.]
Example 2:
In this example, we are creating an array with the complex number to return a Hermite_e series with the given complex roots using hermefromroots.
Python3
# import hermite_e library from numpy.polynomial import hermite_e # generate a Hermite_e series with given # roots using hermefromroots() function print(hermite_e.hermefromroots((-2, 4, 5, 4+5j))) |
Output:
[-127.-165.j -1. -25.j 36. +35.j -11. -5.j 1. +0.j]
Example 3:
In this example, we are creating a NumPy array of 8 elements and returning the Hermite_e series with the given roots using hermefromroots.
Python3
# import hermite_e library from numpy.polynomial import hermite_e import numpy # create an array 'arr' of roots arr = numpy.array([1, 2, 3, 4, 5, 6, 7, 8]) # generate a Hermite_e series with given # roots using hermefromroots() function print(hermite_e.hermefromroots(arr)) |
Output:
[ 2.34086e+05 -3.83256e+05 2.77808e+05 -1.16424e+05 3.08490e+04-5.29200e+03 5.74000e+02 -3.60000e+01 1.00000e+00]



