Show that $\int_{-1}^1f(t)dt = \sum_{i=1}^nw_if(a_i)$ 
If $a_1,...,a_n$ are distinct reals, show that there are scalars
  $w_1,...,w_n$ such that 
$$\int_{-1}^1f(t)dt  = \sum_{i=1}^nw_if(a_i)$$
for all polynomials $f(t)$ in $P_{n-1}$.

I started by evaluating the integral, so we have
$$\int_{-1}^1f(t)dt =\frac{(f(1))^2-(f(-1))^2}{2}$$
But I don't understand how this can always be equal to the sum presented in the problem.
 A: It's enough to remark that each polynomial in $P^{n-1}$ can be written in the following way:
$$f(t) = \sum_{i=1}^n \left(\prod_{k\neq i} \dfrac{t-a_k}{a_i - a_k}\right)f(a_i)$$
This is because LHS - RHS is a polynomial in $P^{n-1}$ which admit all $a_i$'s as $n$ distinct roots, so LHS- RHS is identically zero
Therefore $$\int_{-1}^1f(t)dt  = \sum_{i=1}^n \left(\int_{-1}^1 \left(\prod_{k\neq i} \dfrac{t-a_k}{a_i - a_k}\right)dt\right)f(a_i)$$
Let $\omega_i = \int_{-1}^1 \left(\prod_{k\neq i} \dfrac{t-a_k}{a_i - a_k}\right)dt$, you get what you want.
A: Let $B=(1,t,...,t^{n-1})$ be an ordered basis for $\mathbb{P}^{n-1}$. Consider the linear transformation $\lambda: \mathbb{P}^{n-1} \to \mathbb{R}^n$
given by $\lambda(p) = (p(a_1),...,p(a_n))^T$. Using the basis $B$, the linear transformation $\lambda$ has the Vandermond matrix representation
$\Lambda = \begin{bmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^{n-1} \\
\vdots & \vdots & \vdots & \cdots & \vdots \\
1 & a_n & a_n^2 & \cdots & a_n^{n-1} \end{bmatrix}$, and since the $a_k$ are distinct, we have $\det \Lambda \neq 0$ and so the transformation is invertible.
Define $\phi_k \in \mathbb{P}^{n-1}$ by $\phi_k(t) = \sum_{i=1}^n [\Lambda^{-1} e_k]_i t^{i-1}$, where $e_k$ is the vector of zeros with one in the $k$th position. It is easy to check that $\lambda(\phi_k) = e_k$ and so it follows that the $\phi_k$ form a basis for $\mathbb{P}^{n-1}$.
By construction, we have $\phi_k(a_i) = \delta_{ki}$ (that is, zero for $k\neq i$ and one otherwise). In particular, $\lambda(\sum f_k \phi_k) = (f_1,...,f_n)^T$.
The point of this basis is that given some $f \in \mathbb{P}^{n-1}$, then we have $f = \sum_{k=1}^n f(a_k) \phi_k$.
Then $\int_{-1}^1 f(t) dt = \int_{-1}^1 \sum_{k=1}^n f(a_k) \phi_k(t) dt =
\sum_{k=1}^n f(a_k) \int_{-1}^1 \phi_k(t) dt$. If we let $w_k = \int_{-1}^1 \phi_k(t) dt$ we obtain the desired result.
Since $\phi_k(t) = \sum_{i=1}^n [\Lambda^{-1} e_k]_i t^{i-1}$, we have
$\int_{-1}^1 \phi_k(t) dt = \sum_{i=1}^n [\Lambda^{-1} e_k]_i {(1-(-1)^i) \over i}$.
A: To have these expressions equal for all polynomials in $P_{n-1}$, it is necessary and sufficient to have them equal for powers of $t$ from $0$ to $n-1$. That is: 
$$\int_{-1}^1 t^0 dt  = \sum_{i=1}^n w_i a_i^0$$
$$\int_{-1}^1 t^1 dt  = \sum_{i=1}^n w_i a_i^1$$
$$\dots\dots\dots$$
$$\int_{-1}^1 t^{n-1} dt  = \sum_{i=1}^n w_i a_i^{n-1}$$
The left side is (hopefully) easy to evaluate. So you have $n$ linear equations with $n$ unknowns.
It remains to show that the matrix of this system is invertible. Luckily, it is a Vandermonde matrix.
