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:

    1. edges — bin edges (N+1 doubles).

    2. orders — integration order for each bin (N of size_t).

  • Case B, using std::vector (same order):

    1. edges — bin edges (N+1 doubles).

    2. orders — integration order for all bins (size_t).

  • Case C, using double pointer:

    1. edges — bin edges (N+1 doubles).

    2. orders — integration order for each bin (N of size_t).

    3. bins — number of bins (size_t).

  • Case D, using std::vector (same order):

    1. edges — bin edges (N+1 doubles).

    2. orders — integration order for all bins (size_t).

    3. bins — number of bins (size_t).

Outputs

  1. points.x — array of sample points \(x_i\).

  2. 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:

\[H = \int\limits_{a}^{b} f(x) dx \approx \sum_{j=1}^{M} \omega_j f(x_j).\]

In case of a histogram for each bin \(i\) with limits \((x_i, x_{i+1})\) the integral is given by:

\[H_i = \int\limits_{x_i}^{x_{i+1}} f(x) dx \approx \sum_{j_i=1}^{M_i} \omega_{ij} f(x_{ij}),\]

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.