Question: > 
> Let $a\_1,\ldots,a\_n$ real numbers and $x\_1,\ldots,x\_n$ be distinct real numbers. Show that there is a polynomial of degree at most $n-1$ for which $f(x\_i) = a\_i$ for all $i$.
> 
> 
> 

My idea was to prove the statement for $a\_1 = 1$ and $a\_2 = \cdots = a\_n = 0$. We then have $f(x\_1) = 1$ and $f(x\_m) = 0$ for $1 < n \leq m$. Then I have to construct such a function and see how to construct a function for any sequence of $a\_i's$ and $x\_i's$.

Answer: 
For your specific approach, let
$$f\_1(x)=\frac{(x-x\_2)(x-x\_3)\cdots(x-x\_n)}{(x\_1-x\_2)(x\_1-x\_3)\cdots (x\_1-x\_n)}.$$
Then $f\_1(x)=1$ when $x=x\_1$ and $f\_1(x)=0$ for all the other $x\_i$.

Construct $f\_i(x)$ similarly. Then our interpolating polynomial is a suitable linear combination of the $f\_i(x)$.
$f(X)= \sum\_i a\_i{{(X-x\_1)...\overline{(X-x\_i)}..(X-x\_n)}\over{(x\_i-x\_1)..(x\_i-x\_n)}}$

where $\overline{(X-x\_i)}$ means the expression $(X-x\_i)$ does not appears in the product.