GaussLegendre: 1d quadrature transformation¶
Description¶
Computes the sample points and weights needed to integrate 1d function into a 1d histogram. The integration is done in combination with GaussLegendreHist transformation.
Arguments¶
For a case of \(N\) bins.
Case A, using
std::vector
:edges
— bin edges (N+1 doubles).orders
— integration order for each bin (N of size_t).
Case B, using
std::vector
(same order):edges
— bin edges (N+1 doubles).orders
— integration order for all bins (size_t).
Case C, using
double
pointer:edges
— bin edges (N+1 doubles).orders
— integration order for each bin (N of size_t).bins
— number of bins (size_t).
Case D, using
std::vector
(same order):edges
— bin edges (N+1 doubles).orders
— integration order for all bins (size_t).bins
— number of bins (size_t).
Outputs¶
points.x
— array of sample points \(x_i\).points.xedges
— bin edges.
Tests¶
Use the following commands for the usage example and testing:
./tests/elementary/test_integral_gl1d.py -s
Implementation¶
According to Gauss-Legendre approximation the finite integral of order \(M\) is approximated by:
In case of a histogram for each bin \(i\) with limits \((x_i, x_{i+1})\) the integral is given by:
where \(M_i\) is integration order for each bin \(i\).
For a given set of bin edges and orders the transformation computes sample points (output) and weights (internal). The function of interest should be then computed on \(x\) and passed to GaussLegendreHist instance.
For more information on Gauss-Legendre quadrature see https://en.wikipedia.org/wiki/Gaussian_quadrature.