Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Convert a polynomial to Laguerre series in Python
To convert a polynomial to a Laguerre series, use the laguerre.poly2lag() method in Python NumPy. This function converts an array representing polynomial coefficients (ordered from lowest to highest degree) to an array of equivalent Laguerre series coefficients.
The method returns a 1-D array containing the coefficients of the equivalent Laguerre series. The parameter pol is a 1-D array containing the polynomial coefficients.
Syntax
numpy.polynomial.laguerre.poly2lag(pol)
Parameters
pol: 1-D array containing polynomial coefficients ordered from lowest to highest degree.
Return Value
Returns a 1-D array containing the coefficients of the equivalent Laguerre series.
Example
Let's convert a polynomial with coefficients [1, 2, 3, 4, 5] to its equivalent Laguerre series ?
import numpy as np
from numpy.polynomial import laguerre as L
# Create an array of polynomial coefficients
coefficients = np.array([1, 2, 3, 4, 5])
# Display the polynomial coefficients
print("Polynomial coefficients:", coefficients)
# Check array properties
print("Dimensions:", coefficients.ndim)
print("Datatype:", coefficients.dtype)
print("Shape:", coefficients.shape)
# Convert polynomial to Laguerre series
laguerre_series = L.poly2lag(coefficients)
print("Laguerre series coefficients:", laguerre_series)
Polynomial coefficients: [1 2 3 4 5] Dimensions: 1 Datatype: int64 Shape: (5,) Laguerre series coefficients: [ 153. -566. 798. -504. 120.]
How It Works
The polynomial 1 + 2x + 3x² + 4x³ + 5x? is converted to its equivalent representation using Laguerre polynomials. The resulting coefficients represent the same function but expressed as a linear combination of Laguerre basis functions.
Conclusion
The laguerre.poly2lag() function provides an efficient way to convert polynomial coefficients to Laguerre series representation. This conversion is useful in numerical analysis and approximation theory where Laguerre polynomials offer computational advantages.
