Skip to main content

Module quadrature

Module quadrature 

Source
Expand description

Gauss-Legendre nodes and weights, one root per lane.

The n-point rule integrates polynomials through degree 2n - 1 exactly on [-1, 1]: int f ~ sum_k w_k f(x_k) with x_k the roots of P_n and w_k = 2 / ((1 - x_k^2) P_n'(x_k)^2).

§Shape

The root index k is the lane’s input (0 is the largest root, n - 1 the smallest, x_{n-1-k} = -x_k), and n is uniform, so a packet of consecutive indices is the rule: a caller sweeps k in packets and stores nodes and weights as it goes. Every lane runs the same O(n) recurrence per Newton step, so the packet costs one root, not LANES.

§Method

Tricomi’s seed cos(pi (k + 3/4) / (n + 1/2)) is within O(1/n) of the root and inside its Newton basin (the roots of P_n are separated by about pi/n and the seed’s error is a fraction of that), then newtons_method on P_n with P_n' from the recurrence, P_n'(x) = n (x P_n - P_{n-1}) / (x^2 - 1), two to four steps in practice, eight at most. The recurrence j P_j = (2j - 1) x P_{j-1} - (j - 1) P_{j-2} runs with its two scalar coefficients formed once per j, no vector division. The residual tolerance scales with n, which is the recurrence’s own rounding. Through |P_n'|, that is a few eps absolute on interior nodes and far less at the ends, where P_n' is O(n^2).

Functions§

gauss_hermite_impl
The k-th node and weight of the n-point Gauss-Hermite rule (weight e^{-x^2} on the line), k per lane, k = 0 the largest root.
gauss_laguerre_impl
The k-th node and weight of the n-point Gauss-Laguerre rule (weight x^alpha e^{-x} on [0, inf)), k per lane, k = 0 the largest root, alpha > -1 per lane.
gauss_legendre_impl
The k-th node and weight of the n-point Gauss-Legendre rule, k per lane.
Last built: 2026-09-08 21:35:55 UTC