{ } Raw JSON

bundles / scipy latest / scipy / integrate / _rules / _gauss_legendre / GaussLegendreQuadrature

class

scipy.integrate._rules._gauss_legendre:GaussLegendreQuadrature

source: /scipy/integrate/_rules/_gauss_legendre.py :10

Signature

class   GaussLegendreQuadrature ( npoints xp = None )

Members

Summary

Gauss-Legendre quadrature.

Parameters

npoints : int

Number of nodes for the higher-order rule.

xp : array_namespace, optional

The namespace for the node and weight arrays. Default is None, where NumPy is used.

Examples

Evaluate a 1D integral. Note in this example that ``f`` returns an array, so the estimates will also be arrays.
import numpy as np
from scipy.integrate import cubature
from scipy.integrate._rules import GaussLegendreQuadrature
def f(x):
    return np.cos(x)
rule = GaussLegendreQuadrature(21) # Use 21-point GaussLegendre
a, b = np.array([0]), np.array([1])
rule.estimate(f, a, b) # True value sin(1), approximately 0.84147
rule.estimate_error(f, a, b)

Aliases

  • scipy.integrate._rules.GaussLegendreQuadrature