
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Compute the roots of a Legendre series in Python
To compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python. The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex. The parameter c is a 1-D array of coefficients.
Steps
At first, import the required library −
from numpy.polynomial import legendre as L
To compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python −
print("Result...\n",L.legroots((0, 1, 2)))
Get the datatype −
print("\nType...\n",L.legroots((0, 1, 2)).dtype)
Get the shape −
print("\nShape...\n",L.legroots((0, 1, 2)).shape)
Example
from numpy.polynomial import legendre as L # To compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python print("Result...\n",L.legroots((0, 1, 2))) # Get the datatype print("\nType...\n",L.legroots((0, 1, 2)).dtype) # Get the shape print("\nShape...\n",L.legroots((0, 1, 2)).shape)
Output
Result... [-0.76759188 0.43425855] Type... float64 Shape... (2,)
- Related Articles
- Compute the roots of a Legendre series with given complex roots in Python
- Compute the roots of a Laguerre series in Python
- Compute the roots of a Hermite series in Python
- Compute the roots of a Chebyshev series in Python
- Compute the roots of a Hermite_e series in Python
- Generate a Legendre series with given roots in Python
- Compute the roots of a Laguerre series with given complex roots in Python
- Compute the roots of a Hermite series with given complex roots in Python
- Compute the roots of a Chebyshev series with given complex roots in Python
- Compute the roots of a Hermite_e series with given complex roots in Python
- Generate a Legendre series with given complex roots in Python
- Compute the roots of a polynomial in Python
- Differentiate a Legendre series in Python
- Integrate a Legendre series in Python
- Compute the roots of a polynomial with given complex roots in Python

Advertisements