1. Home
  2. Interpolation & calculus

Integration · product rules

Two-Dimensional Gaussian Quadrature

Eigenfield editorial team ·

Two-dimensional Gaussian quadrature approximates a double integral ∫∫ f(x, y) dx dy by a weighted sum of function values at a small set of well-chosen points. For smooth integrands it reaches high accuracy with a few evaluations, far fewer than a grid of equal weights would need. The method also handles regions where the inner limits for x depend on y, which is the usual meaning of x bounds in this context.

The building block is the one-dimensional Gauss-Legendre rule. An n-point rule on [−1, 1] integrates every polynomial up to degree 2n − 1 exactly. The nodes are the roots of the Legendre polynomial of degree n, and the weights follow from the same polynomial.

Nodes and weights

The two-point rule has nodes ±1/√3 = ±0.577350 and both weights equal 1. The three-point rule has nodes −√(3/5), 0 and +√(3/5), that is −0.774597, 0 and 0.774597, with weights 5/9, 8/9 and 5/9. Their sum is 2, the length of the interval, which is the first check of any table.

For an interval [a, b] the rule is mapped by x = (a + b)/2 + (b − a)/2 · ξ. The nodes move accordingly and every weight is multiplied by (b − a)/2. On [0, 1] the two-point rule uses nodes 0.211325 and 0.788675 with weights 0.5 each.

The product rule

For a rectangle, apply the one-dimensional rule in each variable and multiply the weights: ∫∫ f ≈ ∑ᵢ ∑ⱼ wᵢ wⱼ f(xᵢ, yⱼ). An n by n rule costs n² evaluations and is exact for polynomials of degree 2n − 1 in each variable separately.

Example: f = x²y² on the unit square, whose exact integral is 1/9. In one variable the two-point sum is 0.5 × 0.211325² + 0.5 × 0.788675² = 0.5 × (0.044658 + 0.622008) = 0.333333. Because the integrand separates, the double sum is 0.333333² = 0.111111, which is 1/9 to six digits.

A non-polynomial test: f = e^(x+y) on the unit square has exact value (e − 1)² = 2.952492. The two-point rule gives 0.5 × (e^0.211325 + e^0.788675) = 1.717896 in one variable and 1.717896² = 2.951168 in two, an error of 0.0013. The three-point rule on [0, 1] gives 1.718281 and 2.952490, wrong only in the sixth digit. Adding one node per axis cut the error by a factor of several hundred.

Variable inner bounds

Many regions are not rectangles. Suppose x runs from a lower curve g₁(y) to an upper curve g₂(y), while y runs over [c, d]. The outer rule picks nodes yⱼ on [c, d]. For each yⱼ, a fresh inner rule is mapped onto [g₁(yⱼ), g₂(yⱼ)]. The inner nodes and the inner weight factor (g₂ − g₁)/2 both change from one yⱼ to the next. The outer integrand is the inner integral, itself a function of y.

Example: integrate f = xy over the triangle 0 ≤ x ≤ y ≤ 1. The exact value is ∫₀¹ y · y²/2 dy = 1/8. Use two points in each direction. The outer nodes are y = 0.211325 and 0.788675 with weights 0.5. For each y the inner nodes are x = y × 0.211325 and y × 0.788675, with weights y/2 each. The inner sum is (y/2) × y × y × (0.211325 + 0.788675) = y³/2. With y³ equal to 0.009437 and 0.490563, the outer sum is 0.5 × (0.009437 + 0.490563)/2 = 0.125 exactly, as predicted, because the inner integrand is linear in x and the outer one is a cubic in y.

If the bounds themselves are not smooth, for example when one of them has a kink, the accuracy drops. Split the region at the kink and integrate each piece separately.

Practical notes

Compute the nodes and weights once and reuse them. Tables for 2 to 5 points suffice for many problems.

Doubling the order is not the only way to improve an estimate. Cutting the region into subregions and applying a low-order rule to each is often more reliable than one high-order rule, and it gives a built-in error estimate by comparing two orders on the same pieces. Integrands with singularities or sharp peaks need a change of variable first, since the polynomial exactness argument does not apply to them.

A single formula can also serve for sampled data. Fit an interpolant to the samples with the methods on the two-dimensional interpolation page, then integrate the interpolant. For derivatives, the companion tool is finite differences.

Further numerical tools are grouped under interpolation and calculus.

Back to top