
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Generate a Hermite series with given roots in Python
To generate a Hermite series with given roots, use the hermite.hermfromroots() 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 −
import numpy as np from numpy.polynomial import hermite as H
To generate a Hermite series with given roots, use the hermite.hermfromroots() method in Python Numpy −
print("Result...\n",H.hermfromroots((-1,0,1)))
Get the datatype −
print("\nType...\n",H.hermfromroots((-1,0,1)).dtype)
Get the shape −
print("\nShape...\n",H.hermfromroots((-1,0,1)).shape)
Example
from numpy.polynomial import hermite as H # To generate a Hermite series with given roots, use the hermite.hermfromroots() 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. print("Result...\n",H.hermfromroots((-1,0,1))) # Get the datatype print("\nType...\n",H.hermfromroots((-1,0,1)).dtype) # Get the shape print("\nShape...\n",H.hermfromroots((-1,0,1)).shape)
Output
Result... [0. 0.25 0. 0.125] Type... float64 Shape... (4,)
- Related Articles
- Generate a Hermite series with given complex roots in Python
- Compute the roots of a Hermite series with given complex roots in Python
- Generate a Chebyshev series with given roots in Python
- Generate a Laguerre series with given roots in Python
- Generate a Legendre series with given roots in Python
- Generate a Hermite_e series with given roots in Python
- Generate a Chebyshev series with given complex roots in Python
- Generate a Laguerre series with given complex roots in Python
- Generate a Legendre series with given complex roots in Python
- Generate a Hermite_e series with given complex roots in Python
- Compute the roots of a Hermite series in Python
- Generate a monic polynomial with given roots in Python
- Generate a monic polynomial with given complex roots in Python
- Compute the roots of a Chebyshev series with given complex roots in Python
- Compute the roots of a Laguerre series with given complex roots in Python

Advertisements