4.4.1. tkwant.integration.calc_abscissas_and_weights

tkwant.integration.calc_abscissas_and_weights(a, b, n, quadrature)[source]

Abscissas and weights for fixed-order integration quadratures.

  • a (float) – Lower limit of integration.

  • b (float) – Upper limit of integration.

  • n (int) – Order of quadrature integration. Must be positive, n > 0

  • quadrature (string) –

    Quadrature rule to use. Possible choices:

    • gausslegendre: order n Gauss-Legendre

    • kronrod: order n and 2 n + 1 Gauss-Kronrod

    • trapezoidal: n point trapezoidal rule

    • trapezoidal-2: n and 2 n - 1 point trapezoidal rule


  • x (Numpy float array) – abscissa values

  • w (Numpy float array) – quadrature weights


  • For the Guass-Legendre quadrature, both x and w are one-dimensional numpy arrays of shape (n, ). A one-dimensional integral \(\int_a^b f(x) dx\) can be approximated by an order n quadrature via np.sum(w * f(x)).

  • For the Gauss-Kronrod quadrature, x is a one dimensional numpy array of shape (2*n+1,) and w is a two-dimensional array of shape (2, 2*n+1). A one-dimensional integral \(\int_a^b f(x) dx\) can be approximated by result = np.sum(w * f(x), axis=1). The element result[0] then corresponds to the lower-order (n) and the second element result[1] corresponds to the higher-order (2*n + 1) approximation of the integral.

  • For general quadratures with array-like weights aka Gauss-Kronrod, we use the convention that the last element of the first array index corresponds to the higher-order rule.