Open In App

Convert a Laguerre series to a polynomial in Python

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Laguerre polynomials are a sequence of orthogonal polynomials that arise in various problems in physics and engineering, particularly in quantum mechanics and numerical analysis. They are solutions to Laguerre's differential equation and are used to express functions in terms of a series expansion known as a Laguerre series. In many applications, it is useful to convert a Laguerre series into a standard polynomial form. This article explores what a Laguerre series is and demonstrates two methods to perform this conversion in Python.

What is a Laguerre Series?

A Laguerre series is a representation of a function in terms of Laguerre polynomials. The generalized Laguerre polynomials L_n^{(\alpha)}(x) are defined by the Rodrigues' formula:

L_n^{(\alpha)}(x) = \frac{e^x x^{-\alpha}}{n!} \frac{d^n}{dx^n} \left( e^{-x} x^{n+\alpha} \right)

For the special case where α=0, these polynomials are referred to as the "standard" Laguerre polynomials. A function f(x) can be approximated by a finite Laguerre series:

f(x) \approx \sum_{n=0}^{N} c_n L_n^{(\alpha)}(x)

where cn are the coefficients of the series. Converting this series to a standard polynomial involves expressing the Laguerre polynomials in their expanded polynomial form and then combining like terms.

Convert a Laguerre series to a polynomial in Python

Method 1: Using SymPy

SymPy is a Python library for symbolic mathematics. It provides tools to work with polynomial expansions and symbolic representations of mathematical expressions, including Laguerre polynomials.

pip install sumpy

This code will output the polynomial representation of the given Laguerre series. By expanding each Laguerre polynomial and combining them with the corresponding coefficients, we obtain the equivalent standard polynomial.

Python
import sympy as sp

# Define the variable and the degree of the polynomial
x = sp.symbols('x')
degree = 4

# Generate Laguerre polynomials and their coefficients
coefficients = [1, 2, 3, 4, 5]  # Example coefficients for the Laguerre series
laguerre_polynomials = [sp.laguerre(n, x) for n in range(degree + 1)]

# Convert Laguerre series to polynomial
polynomial = sum(c * L for c, L in zip(coefficients, laguerre_polynomials))

# Simplify and display the polynomial
polynomial = sp.expand(polynomial)
print(polynomial)

Output

5*x**4/24 - 4*x**3 + 45*x**2/2 - 40*x + 15

Method 2: Using NumPy

NumPy, a fundamental library for scientific computing in Python, also supports operations with Laguerre polynomials. It includes the numpy.polynomial.laguerre module, which can be used to handle Laguerre series.

pip install numpy

The output will be the coefficients of the equivalent standard polynomial. The convert method in the Laguerre class transforms the Laguerre series into a standard polynomial, which can be evaluated or manipulated as needed.

Python
import numpy as np
from numpy.polynomial.laguerre import Laguerre

# Define the coefficients of the Laguerre series
coefficients = [1, 2, 3, 4, 5]  # Example coefficients for the Laguerre series

# Create a Laguerre series using the given coefficients
laguerre_series = Laguerre(coefficients)

# Convert the Laguerre series to a standard polynomial
polynomial = laguerre_series.convert(kind=np.polynomial.Polynomial)

# Display the polynomial coefficients
print(polynomial)

Output

15.0 - 40.0 x + 22.5 x**2 - 4.0 x**3 + 0.20833333 x**4

Article Tags :
Practice Tags :

Similar Reads