Eigenvalue problem-Expand the function to the eigenfunctions of the problem Having solved the eigenvalue problem $$y''+ λ y=0, 0 \leq x \leq L$$
$$y(0)=y(L)=0$$
which solution is:
$$\text{The eigenvalues are: } λ_n=(\frac{n \pi}{L})^2$$
$$\text{ and the eigenfuctions are: }y_n=\sin (\frac{n \pi x}{L})$$
I am asked to expand the function $f(x)=2$ to the eigenfunctions of the problem.
At an other exercise in my notes there is the following:
$$\text{Since the problem is Sturm-Liouville, each function } f(x), 0 \leq x \leq L \text{ with } f(0)=f(L)=0, \text{ can be written as a sum of the eigenfunctions, so}$$
$$f(x)=\sum_{n=1}^{\infty}{c_n \sin(\frac{n \pi x}{L})}$$
But in this case $f(x)=2$ and it does not stand that $f(0)=f(L)=0$. What can I do? Can I use the sentence above though?
 A: Think of all $v_n=\sin(\frac{n \pi x}{L})$ with $n\in \mathbb Z$ as vectors.
The set $B=\{v_n\}$ forms a basis for the space of functions defined over $0<x<L$, a space of infinite dimension (the dimension of a space is given by the number of elements necessary to form a basis). For a given set of vectors to form a basis, the requirements are that they are linearly independent, and that, by a linear combination of them, you can represent any other vector in the vector space.
If you define the inner product $<f,g>=\int_{0}^{L}fg dx$, you can say it's an orthogonal basis for the space of functions, since $<v_i,v_j>=0$ if $i\neq j$, and $<v_i,v_i>=L/2$.
If you define the inner product $<f,g>=\frac{2}{L}\int_{0}^{L}fg dx$, you can say it's an orthonormal basis for the space of functions, since $<v_i,v_j>=0$ if $i\neq j$, and $<v_i,v_i>=1$. Let's take this definition for the inner product.
Note that the definitions of inner product above, posses the usual properties of the dot-product: Positive-definiteness,symmetry and linearity (asociativity, distributivity), which is a requirement for this reasoning to work.
What you now want to know is what are all the components of $f(x)=2$ in each of the 'directions' forming the basis, the $c_n$. Let's compute them: 
$$c_n=<f,v_n>=\frac{2}{L}\int_{0}^{L}2 \sin(\frac{n \pi x}{L}) dx=\frac{4 ((-1)^{n+1}+1)}{\pi  n}$$
Here is what you get:

