Numerical quadrature from Lagrange

The general idea of numerical integration: approximate an integral by a weighted sum of function values, obtained by integrating the Lagrange polynomial.

What problem it solves

Many integrals cannot be computed by hand because the function is only tabulated or because its antiderivative is not manageable. Numerical quadrature replaces the exact area by a combination of heights measured at nodes.

I=abf(x)dxi=0naif(xi)I=\int_a^b f(x)\,dx\approx\sum_{i=0}^{n} a_i f(x_i)
General form of a quadrature rule.

Derivation with the interpolating polynomial

If we interpolate ff with the Lagrange polynomial pnp_n and then integrate, the integral of ff separates into a sum of values f(xi)f(x_i) multiplied by integrals of the bases LiL_i.

pn(x)=i=0nLi(x)f(xi),Li(x)=jixxjxixjp_n(x)=\sum_{i=0}^{n}L_i(x)f(x_i),\qquad L_i(x)=\prod_{j\ne i}\frac{x-x_j}{x_i-x_j}
abf(x)dxi=0nf(xi)abLi(x)dx\int_a^b f(x)\,dx\approx\sum_{i=0}^{n} f(x_i)\int_a^b L_i(x)\,dx
The weights are integrals of the Lagrange bases.
E=1(n+1)!abf(n+1)(ξ(x))i=0n(xxi)dxE=\frac{1}{(n+1)!}\int_a^b f^{(n+1)}(\xi(x))\prod_{i=0}^{n}(x-x_i)\,dx
Quadrature error associated with the interpolation term.

Which method to choose

  • If the nodes are equally spaced and the endpoints are used, closed Newton-Cotes formulas appear.
  • If the nodes are equally spaced but the endpoints are not used, open Newton-Cotes formulas appear.
  • If the evaluation points can be chosen, Gaussian quadrature places non-equally spaced nodes to increase the degree of exactness.
  • For double integrals, the same rules are applied as a product: one direction and then the other.