![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Generate a Hermite series with given complex roots in Python
To generate a Hermite series with given complex 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 −
from numpy.polynomial import hermite as H
To generate a Hermite series with given complex roots, use the hermite.hermfromroots() method −
j = complex(0,1) print("Result...\n",H.hermfromroots((-j, j)))
Get the datatype −
print("\nType...\n",H.hermfromroots((-j, j)).dtype)
Get the shape −
print("\nShape...\n",H.hermfromroots((-j, j)).shape)
Example
from numpy.polynomial import hermite as H # To generate a Hermite series with given complex 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. j = complex(0,1) print("Result...\n",H.hermfromroots((-j, j))) # Get the datatype print("\nType...\n",H.hermfromroots((-j, j)).dtype) # Get the shape print("\nShape...\n",H.hermfromroots((-j, j)).shape)
Output
Result... [1.5 +0.j 0. +0.j 0.25+0.j] Type... complex128 Shape... (3,)
Advertisements