TITLE: Quadrature formula
QUESTION [5 upvotes]: How can we find a quadrature formula $\int_{-1}^1 f(x) dx=c \displaystyle \sum_{i=0}^{2}f(x_i)$ that is exact for all quadratic polynomials?
Thanks for help.

REPLY [7 votes]: Write:
$$\int_{-1}^{1} f(x)\ dx =\int_{-1}^{1} ax^2+bx+c\ dx =\frac{2a}{3}+2c$$
Moreover you want to have three points all having the same weights. To make life simpler, let's also assume symmetry:
$$w\left(f(-x_0)+f(0)+f(x_0)\right) =\frac{2a}{3}+2c$$
$$w\left(2ax_0^2+3c\right)=\frac{2a}{3}+2c$$
It's clear that $w$ must be $2/3$, and so:
$$x_0^2 = 1/2 \to x_0=1/\sqrt{2}$$
All in all you have:
$$\int_{-1}^{1} f(x)\ dx \sim \frac{2}{3}\left(f(-1/\sqrt{2})+f(0)+f(1/\sqrt{2}) \right)$$
Edit: You can of course choose any three points and still get exact results, but this makes the calculation far less elegant.