Generate a Hermite_e series with given roots using NumPy in Python
Last Updated :
25 Jul, 2022
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]
Similar Reads
Generate Chebyshev series with given complex roots using NumPy in Python In this article, we will cover how to generate the Chebyshev series with given complex roots in Python using NumPy. Example Input: (4+5j) Output: [9.5-40.j 0. +0.j 0.5 +0.j] Explanation: An array of Chebyshev series.chebyshev.chebfromroots() method In python, the Chebyshev module provides many funct
2 min read
Compute the Roots of a Hermite_e series with given Complex Roots using NumPy in Python In this article, we are going to see how to compute the roots of a Hermite_e series with given complex roots in Python. NumPy hermeroots() Methods We use the hermite e.hermeroots() function in Python Numpy to get the roots of a Hermite e series. This function will return an array containing the seri
2 min read
Generate a Legendre series with given roots in Python In this article, we will see how to generate a Legendre series with given roots in Python. Legendre classIn python, the Legendre module provides many functions like legfromroots to perform arithmetic, and calculus operations on the Legendre series. It is one of the functions provided by the Legendre
2 min read
Generate a Legendre series with given complex roots in Python In this article, we will cover how to generate the Legendre series with given complex roots in Python using NumPy. ExampleInput: (4+5j) Output: [9.33333333-40.j 0. +0.j 0.66666667 +0.j] Explanation: An array of legendre series.legendre.legfromroots method In python, the Legendre module provides many
2 min read
Divide one Hermite series by another in Python using NumPy In this article, we are going to see how to divide one Hermite series by another in Python using NumPy. The numpy hermdiv() method helps us divide one Hermite series by another. The quotient and remainder of two Hermite series, c1 / c2, are returned. The arguments are a series of coefficients from l
3 min read