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

bundles / scipy latest / scipy / special / _orthogonal / roots_sh_legendre

function

scipy.special._orthogonal:roots_sh_legendre

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

Signature

def roots_sh_legendre(n, mu = False)

Summary

Gauss-Legendre (shifted) quadrature.

Extended Summary

Compute the sample points and weights for Gauss-Legendre quadrature. The sample points are the roots of the nth degree shifted Legendre polynomial . These sample points and weights correctly integrate polynomials of degree or less over the interval with weight function . See 22.2.11 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

Compute nodes and weights for a 7th-order shifted Gauss-Legendre quadrature:
from scipy.special import roots_sh_legendre, eval_sh_legendre
x, w = roots_sh_legendre(7)
✓
x
w
✗
array([0.06474, 0.13985, 0.19092, 0.20898, 0.19092, 0.13985, 0.06474])
Verify that ``x`` are the roots of the degree-7 shifted Legendre polynomial:
eval_sh_legendre(7, x)
✗
array([ 0.,  0.,  0.,  0., -0., -0., -0.])
The sum of the weights for shifted Gauss-Legendre quadrature is always 1:
x, w, mu = roots_sh_legendre(10, mu=True)
✓
mu
✗
1.0

See also

scipy.integrate.fixed_quad

Aliases

  • scipy.special.ps_roots