This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / special / _orthogonal / roots_laguerre

function

scipy.special._orthogonal:roots_laguerre

source: build-install/usr/lib/python3.14/site-packages/scipy/special/_orthogonal.py:925

Signature

def roots_laguerre(n, mu = False)

Summary

Gauss-Laguerre quadrature.

Extended Summary

Compute the sample points and weights for Gauss-Laguerre quadrature. The sample points are the roots of the nth degree Laguerre polynomial, . These sample points and weights correctly integrate polynomials of degree or less over the interval with weight function . See 22.2.13 in [AS] for details.

Parameters

n : int

quadrature order

mu : bool, optional

If True, return the sum of the weights, optional.

Returns

x : ndarray

Sample points

w : ndarray

Weights

mu : float

Sum of the weights

Examples

from scipy.special import roots_laguerre
roots, weights = roots_laguerre(5)
✓
roots
weights
✗
array([0.522, 0.399, 0.076, 0.004, 0.   ])
Verify that the values in `roots` are roots of the Laguerre polynomial :math:`L_5(x)`.
from scipy.special import eval_laguerre
✓
eval_laguerre(5, roots)
✗
array([-0., -0.,  0., -0., -0.])
The values of :math:`L_5(x)` evaluated at the roots are indeed rather close to zero. The increasing values for larger roots can be explained by the increasing derivative of the Laguerre polynomial at the roots. Verify that the sum of the weights equals the integral from 0 to :math:`\infty` of :math:`\exp(-x)` which evaluates to 1. There are two ways to obtain the sum of weights, both resulting in 1 within numerical precision.
sum(weights)
roots, weights, sum_of_weights = roots_laguerre(5, mu=True)
sum_of_weights
✓
np.float64(1.0)
Roots and weights obtained from the Laguerre polynomial :math:`L_n(x)` are used in Gauss-Laguerre quadrature where the integral from 0 to :math:`\infty` of :math:`f(x)\exp(-x)` is evaluated. Roots and weights for order :math:`n` are expected to yield the exact result for polynomials :math:`f(x)` of a maximal order of :math:`2n-1`.
f = lambda x: x**4
weights @ f(roots)
✓
np.float64(24.000000000000014)
This result is indeed very close to the exact value of 24. In general, Gauss-Laguerre quadrature will only yield an approximate value of the integral. Consider the integral from 0 to :math:`\infty` of :math:`\cos(x)\exp(-x)` which evaluates to 1/2.
import numpy as np
weights @ np.cos(roots)
✓
np.float64(0.5005384852176379)

See also

numpy.polynomial.laguerre.laggauss
scipy.integrate.fixed_quad

Aliases

  • scipy.special.l_roots