$f_n(x)$ are eigenfunctions for a sturm-liouville eq. Prove $f(x) = \sum_{n=0}^{\infty}a_nf_n(x)$ is uniquely represented 
Let $f_n(x)$ be eigenfunctions and $f(x)$ be continuous. Show that the
  expression:
$$f(x) = \sum_{n=0}^{\infty}a_nf_n(x)$$
is unique

These eigenvalues are from the sturm-liouville equation
$$\frac{d}{dx}\left[p(x)\frac{d}{dx}f_n(x)\right]+q(x)f_n(x) + \lambda_nw(x)f_n(x) = 0$$
(I guess).
By the sturm-liouville theory, I know that if $f_n$ and $f_k$ are solutions to the sturm-liouville equations:
$$Lf_n+\lambda_nwf_n = 0$$
$$Lf_k+\lambda_kwf_k = 0$$
then doing this multiplication:
$$f_k(Lf_n+\lambda_nwf_n) = 0$$
$$f_n(Lf_k+\lambda_kwf_k) = 0$$
,subtracting and integrating, we have:
$$\int_a^b f_kLf_n \ dx -\int_a^b f_nLf_k \ dx = (\lambda_n-\lambda_k)\int_a^b wf_kf_n \ dx$$
that is, for different eigenvalues $\lambda_n, \lambda_k$, we have $f_k$ and $f_n$ orthogonal.
I think the $f_n$'s are already expected to be there, I must therefore prove that the $a_n$'s are unique, right?
What I tried:
Take the last equation but suppose there are two possibilities:
$$f(x) = \sum_{n=0}^{\infty}a_nf_n(x)$$
$$f(x) = \sum_{n=0}^{\infty}a_mf_n(x)$$
and do:
$$f(x)-f(x) = 0 = \sum_{n=0}^{\infty}(a_n-a_m)f_n(x)$$
Multiply by another eigenfunction $f_m$ and integrate:
$$0 =  \sum_{n=0}^{\infty}\int_a^b(a_n-a_m)f_n(x)f_m(x)\ dx = \sum_{n=0}^{\infty}(a_n-a_m)\int(f_n(x)f_m(x))\ dx$$
I thought that the orthogonality of the eigenfunctions would help but I didn't use an weight function $w$ and also that expression won't make $a_n-a_m = 0$. What should I do?
 A: You are on the right track! You just made a slight mistake when writing down the summations. They should say:
$$ f(x) = \sum_{n = 0}^\infty a_n f_n(x), \ \ \ \ \ f(x) = \sum_{n = 0}^\infty b_n f_n(x).$$
The goal is to prove that $a_n = b_n$ for every value of $n$.
Taking the differences, we get
$$ \sum_{n=0}^\infty (a_n - b_n)f_n (x) = 0.$$
Now suppose we want to extract the coefficeint $a_{2017}-b_{2017}$. To do this, we multiply both sides by $f_{2017}(x)w(x)$ and integrate:
$$ \sum_{n = 0}^\infty \int_a^b (a_n - b_n) f_n(x) f_{2017}(x) w(x) dx = 0.$$
[Notice that I multiplied by $f_{2017}(x)w(x)$, not by $f_{2017}(x)$. This resolves your problem about the missing $w(x)$.]
But by the orthogonality relations that you proved in the first half of your post, you know that $$\int_a^b f_n(x) f_{2017}(x) w(x) dx = 0 \ \ \ \ \ {\rm for \ } n \neq 2017$$
Therefore, only the $n = 2017$ term contributes to the sum, and hence
$$ (a_{2017} - b_{2017}) \int f_{2017}(x) f_{2017}(x) w(x) dx = 0,$$
and since $\int f_{2017}(x) f_{2017}(x) w(x) dx > 0$, this implies that
$$a_{2017} - b_{2017} = 0.$$
Of course, there is nothing special about the number $2017$. You can do this for any value of $n$.

While we're discussing this, I strongly suggest that you try to use the same method to show that 
$$ a_n = \frac{\int_a^b f(x)f_n(x) w(x) dx}{\int_a^b f_n(x)f_n(x) w(x) dx}.$$
This is a very useful result.
I also suggest you think about how this method is similar to the way you solve the linear algebra problem of extracting the coordinates $c_n$ of a vector $v = \sum_n c_n e_n$ with respect to an orthogonal basis $e_n$ by orthogonal projection.
