pyhs3.normalization.gauss_legendre_integral¶
- pyhs3.normalization.gauss_legendre_integral(expression, variable, lower, upper)[source]¶
Compute a definite integral symbolically via Gauss-Legendre quadrature.
Gauss-Legendre quadrature approximates the integral over \([a, b]\) by evaluating the integrand at specific nodes and summing with weights. This implementation uses 64-point quadrature, which integrates polynomials up to degree 127 exactly.
The standard Gauss-Legendre formula is defined on \([-1, 1]\):
\[\int_{-1}^{1} f(t)\,dt \approx \sum_{i=1}^{N} w_i\,f(t_i)\]To integrate over an arbitrary interval \([a, b]\), we apply a linear change of variables:
\[x = \frac{b-a}{2}t + \frac{a+b}{2}, \quad t \in [-1, 1], \quad x \in [a, b]\]The Jacobian \(dx = \frac{b-a}{2}dt\) (the “half width”) transforms the integral to:
\[\int_a^b f(x)\,dx = \frac{b-a}{2} \int_{-1}^{1} f\left(\frac{b-a}{2}t + \frac{a+b}{2}\right) dt\]Applying Gauss-Legendre quadrature yields:
\[\int_a^b f(x)\,dx \approx \frac{b-a}{2} \sum_{i=1}^{N} w_i\,f\left(\frac{b-a}{2}t_i + \frac{a+b}{2}\right)\]where \(t_i\) are the standard Legendre nodes and \(w_i\) are the standard weights on \([-1, 1]\).
- Parameters:
expression (
TensorVariable[TensorType,Apply[Any]]) – The PyTensor expression to integratevariable (
TensorVariable[TensorType,Apply[Any]]) – The PyTensor variable to integrate overlower (
TensorVariable[TensorType,Apply[Any]]) – Lower bound \(a\) (PyTensor expression)upper (
TensorVariable[TensorType,Apply[Any]]) – Upper bound \(b\) (PyTensor expression)
- Return type:
TensorVariable[TensorType,Apply[Any]]- Returns:
Symbolic integral as a PyTensor expression