The trapezoid and Simpson rules use equally spaced points and choose only the weights. Gauss had a better idea: choose the points too. With $n$ points there are $2n$ numbers to choose, so a rule can be made exact for all polynomials of degree up to $2n - 1$, which is what interpolation at $n$ fixed points could never do.
Key idea
Why it works
Worked example: Exact for a cubic
- At $\pm\frac{1}{\sqrt{3}}$ the $x^{3}$ terms cancel, and $x^{2} = \frac{1}{3}$ at both.
- Sum: $2\left(\frac{1}{3} + 1\right) = \frac{8}{3}$.
- Exact: $0 + \frac{2}{3} + 2 = \frac{8}{3}$. ✓
Answer: $\frac{8}{3}$
Worked example: On another interval
- Nodes: $\frac{1}{2} \pm \frac{1}{2\sqrt{3}} \approx 0.2113249$ and $0.7886751$.
- Weights: $\frac{b - a}{2} = \frac{1}{2}$ each.
- $\frac{1}{2}\left(e^{0.2113249} + e^{0.7886751}\right) \approx 1.717896$. The exact value is $1.718282$: error $3.9 \times 10^{-4}$.
- Simpson's rule with 3 points has error $5.8 \times 10^{-4}$: two well-placed points beat three equally spaced ones.
Answer: $\approx 1.717896$
Worked example: One degree too many
- $\left(\frac{1}{\sqrt{3}}\right)^{4} \times 2 = \frac{2}{9}$, but the integral is $\frac{2}{5}$.
- Error $\frac{2}{9} - \frac{2}{5} = -\frac{8}{45}$: degree 4 is beyond $2n - 1 = 3$.
Answer: $\frac{2}{9}$, error $-\frac{8}{45}$
Where do the nodes come from in general? They are the zeros of the Legendre polynomial $P_n$, the polynomials that are orthogonal on $[-1, 1]$; that orthogonality is exactly what makes the rule exact up to degree $2n - 1$. The weights are all positive, which keeps the rule stable. The price: the nodes for $n$ and $n + 1$ points share nothing (apart from $0$), so increasing $n$ throws away all earlier function values. Practical codes therefore use a fixed $n$ on many panels (composite Gauss), or pairs of rules built to share nodes (Gauss–Kronrod), which also give an error estimate.
| points $n$ | nodes on $[-1, 1]$ | weights | exact up to degree |
|---|---|---|---|
| 1 | $0$ | $2$ | 1 |
| 2 | $\pm\frac{1}{\sqrt{3}}$ | $1, 1$ | 3 |
| 3 | $0, \pm\sqrt{\frac{3}{5}}$ | $\frac{8}{9}, \frac{5}{9}, \frac{5}{9}$ | 5 |
Common mistake