Compute the roots of a Laguerre series in Python

To compute the roots of a Laguerre series, use the laguerre.lagroots() method in Python NumPy. The method returns an array of the roots of the series. If all the roots are real, then the output is also real, otherwise it is complex.

The root estimates are obtained as the eigenvalues of the companion matrix. Roots far from the origin of the complex plane may have large errors due to the numerical instability of the series for such values. Roots with multiplicity greater than 1 will also show larger errors as the value of the series near such points is relatively insensitive to errors in the roots. Isolated roots near the origin can be improved by a few iterations of Newton's method.

Syntax

numpy.polynomial.laguerre.lagroots(c)

Parameters

c : array_like - 1-D array of Laguerre series coefficients ordered from low to high degree.

Return Value

Returns a 1-D array containing the roots of the Laguerre series. The array is real if all roots are real, otherwise complex.

Example

Let's compute the roots of a simple Laguerre series ?

from numpy.polynomial import laguerre as L

# Compute the roots of a Laguerre series
coefficients = [0, 1, 2]
roots = L.lagroots(coefficients)

print("Coefficients:", coefficients)
print("Roots:", roots)
print("Data type:", roots.dtype)
print("Shape:", roots.shape)
Coefficients: [0, 1, 2]
Roots: [0.69722436 4.30277564]
Data type: float64
Shape: (2,)

Complex Roots Example

When the Laguerre series has complex roots, the output will be complex ?

from numpy.polynomial import laguerre as L

# Example with complex coefficients
coefficients = [1, 2, 3, 1]
roots = L.lagroots(coefficients)

print("Coefficients:", coefficients)
print("Roots:", roots)
print("Data type:", roots.dtype)
Coefficients: [1, 2, 3, 1]
Roots: [0.50990195+0.71270509j 0.50990195-0.71270509j 4.98019609+0.j        ]
Data type: complex128

Verification of Roots

You can verify the computed roots by evaluating the Laguerre series at the root values ?

from numpy.polynomial import laguerre as L
import numpy as np

# Compute roots
coefficients = [0, 1, 2]
roots = L.lagroots(coefficients)

# Verify by evaluating the series at root values
for i, root in enumerate(roots):
    value = L.lagval(root, coefficients)
    print(f"Root {i+1}: {root:.6f}, Series value: {value:.2e}")
Root 1: 0.697224, Series value: -4.44e-16
Root 2: 4.302776, Series value: 1.78e-15

Conclusion

The lagroots() method efficiently computes roots of Laguerre series using companion matrix eigenvalues. Use it for polynomial root finding in numerical analysis and scientific computing applications.

Updated on: 2026-03-26T20:29:25+05:30

415 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements