bundles / scipy latest / scipy / special / _orthogonal / roots_legendre
function
scipy.special._orthogonal:roots_legendre
Signature
def roots_legendre ( n , mu = False ) Summary
Gauss-Legendre quadrature.
Extended Summary
Compute the sample points and weights for Gauss-Legendre quadrature [GL]. The sample points are the roots of the nth degree Legendre polynomial . These sample points and weights correctly integrate polynomials of degree or less over the interval with weight function . See 2.2.10 in [AS] for more details.
Parameters
n: intquadrature order
mu: bool, optionalIf True, return the sum of the weights, optional.
Returns
x: ndarraySample points
w: ndarrayWeights
mu: floatSum of the weights
Examples
import numpy as np from scipy.special import roots_legendre, eval_legendre roots, weights = roots_legendre(9)✓
roots weights✗
eval_legendre(9, roots)
✗def f(t): return t + 1/t a = 1 b = 2✓
t = (b - a)/2 * roots + (a + b)/2
✓(b - a)/2 * f(t).dot(weights)
✗1.5 + np.log(2)
✗See also
- numpy.polynomial.legendre.leggauss
- scipy.integrate.fixed_quad
Aliases
-
scipy.special.p_roots