Find constants $x_i$ such that $\int_{-1}^1 p(t)\,{\rm d}t = x_1p\left(-\frac 12\right) + x_2p(0) + x_3p\left(\frac 12\right)$ 
Find numbers $x_1, x_2, x_3$ such that
  $$\int_{-1}^1 p(t)\,{\rm d}t = x_1p\left(-\frac 12\right) + x_2p(0) + x_3p\left(\frac 12\right)$$ for all polynomials of degree $\le 2$.

I'm not really sure how to even approach this problem. One of the hints our teacher gave us was that to check if the formula is true we can just check it for polynomials $1$, $t$, and $t^2$.
Any help would be appreciated. Thanks!
 A: A general polynomial of degree $2$ is
$$ p(t) = at^2+bt+c. $$
Since the integral is linear, the equation becomes
$$ a\int_{-1}^1 t^2 \, dt + b\int_{-1}^1 t \, dt + c \int_{-1}^1 dt \\
= x_1(a(-1/2)^2+b(-1/2)+c)+ x_2 (c) + x_3 (a(1/2)^2+b(1/2)+c) $$
Since this has to be true for any values of $a,b,c$, you can set two of them to $0$ and solve for the third, for each of $a,b,c$. Or, you can write it as
$$ a\left( \int_{-1}^1 t^2 \, dt-x_1(-1/2)^2-x_3(1/2)^2 \right) + b(\dots)+ c(\dots) = 0, $$
and then note that in order for the left-hand side to vanish, all three brackets have to be zero.
Either way, this gives you 3 simultaneous linear equations for $x_1,x_2,x_3$, which you can easily solve to find their values.
A: If $p(x)$ is a polynomial of degree less than $3$ then the Lagrange interpolating polynomial of $p(x)$ using the three distinct points $a_1,a_2$ and $a_3$ is exact and reads
$$p(x) = p(a_1)\cdot \frac{(x-a_2)(x-a_3)}{(a_1-a_2)(a_1-a_3)} + p(a_2)\cdot \frac{(x-a_1)(x-a_3)}{(a_2-a_1)(a_2-a_3)} + p(a_3)\cdot \frac{(x-a_1)(x-a_2)}{(a_3-a_1)(a_3-a_2)}$$
Integrating over $[-1,1]$ gives us the slightly more general result
$$\int_{-1}^1p(x){\rm d}x = x_1p(a_1) + x_2p(a_2) + x_3p(a_3)$$
where
$$x_1 = \int_{-1}^1\frac{(x-a_2)(x-a_3)}{(a_1-a_2)(a_1-a_3)}{\rm d}x = \frac{2 + 6a_2a_3}{3(a_1-a_2)(a_1-a_3)}\\
x_2 = \int_{-1}^1\frac{(x-a_1)(x-a_3)}{(a_2-a_1)(a_2-a_3)}{\rm d}x = \frac{2 + 6a_1a_3}{3(a_2-a_1)(a_2-a_3)}\\
x_3 = \int_{-1}^1\frac{(x-a_1)(x-a_2)}{(a_3-a_1)(a_3-a_2)}{\rm d}x = \frac{2 + 6 a_1a_2}{3(a_3-a_1)(a_3-a_2)}$$
Taking $\{a_1,a_2,a_3\} = \{-1/2,0,1/2\}$ gives the desired formula. 
Note that the procedure above can be generalized. If $p(x)$ is a polynomial of degree less than $n$ then the Lagrange interpolating polynomial using $n$ distinct points is exact and we can do the same computation as above to get an identity on the form
$$\int_{-1}^1p(x){\rm d}x = x_1p(a_1) + x_2p(a_2) + \ldots + x_np(a_n)$$
where the $x_i$'s are functions of the $a_i$'s which can be computed using the Lagrange formula. Such a formula can for example be used to make numerical integration algorithms.
A: We have $$\begin{align*}
\int_{-1}^1 1 \, dt &= 2 = x_1 + x_2+x_3.\\
\int_{-1}^1 t \, dt &= 0 = \frac{-1}{2} x_1 + \frac{1}{2}x_3.\\
\int_{-1}^1 t^2 \, dt &= \frac 2 3 =  \frac{1}{4} x_1 + \frac{1}{4}x_3.
\end{align*}$$
From the second equality, we have $x_1 = x_3$, so the third yields $x_1 = \frac 4 3$, and so $x_2 = \frac{-2}{3}.$
