Fourier Series, Sturm-Liouville Problem - What is the connection that I'm missing? Fourier Series
So in my book we are talking about Fourier Series. $$f(x) = \frac{1}{2}a_0+\sum_{n=1}^\infty\left[a_n\sin{\left(\frac{n\pi x}{L}\right)}+b_n\cos{\left(\frac{n\pi x}{L}\right)}\right]$$ It says the represents "fairly nice" periodic functions of period $L$.
Sturm Liouville Problem
A sturm liouville problem is one where $$(p(x)y')'+q(x)y+\lambda w(x)y=0 \qquad p(x),w(x)>0 \qquad \text{on} \qquad x_0 \leq x \leq x_1$$ with Boundary Conditions that allow self-adjointness i.e. Dirichlet, Neumann, Singular POint, Periodic or Radiation.
Solution of Sturm Liouville Problem
When solving the SL problem, we normally look at  three different values for $\lambda$ ($0,>0,<0$), find the eigenvalues (which are all positive and real), find the eigenfunctions (which are all real) and so if I pick any eigenvalue and its respective eigenfunction, that is a solution to the SL problem (i.e. the Differential Equation with those eigenvalues substituted to lambda has a solution, the eigenfunction, that respects the Boundary Conditions).
Connection between the two
My book then briefly says that "$\sin{\left(\frac{n\pi x}{L}\right)}$ and $\cos{\left(\frac{n\pi x}{L}\right)}$ are eigenfunctions of the SL problem $y''+\lambda y=0$ on $[-L,L]$ with periodic BCs. And that $$\left\{1, \sin{\left(\frac{n\pi x}{L}\right)}, \cos{\left(\frac{n\pi x}{L}\right)}\right\}$$ form an orthogonal basis for the space of $2L$ -periodic "nice" functions."
My trial
So I tried, using $w(x)=1$, $q(x)=0$, $p(x)=1$, on $[-L,L]$ with $y(-L)=y(L)$ and $y'(-L)=y'(L)$


*

*$\lambda =0$ gives $y=Ax+B$ and applying the conditions gives $A=0$. However doesn't tell us anything about B.

*$\lambda=-\mu^2$ ($\mu\neq 0$) gives $y=Ae^{\mu x}+Be^{-\mu x}$ and applying the conditions gives only the trivial solution $y\equiv 0$

*$\lambda=\mu^2$ ($\mu\neq 0$) gives $y =A\sin{(\mu x)}+B\cos{(\mu x)}$ and applying the conditions gives$\mu=\frac{n\pi}{L}$ only.


However I don't know how to continue to connect the two. I got another solution from the case $\lambda =0$, how do I unify everything?
But in general my question is 

What is the connection between fourier series and SL problems? How can I show that sin and cos are eigenfunctions of that particular sturm liouville problem? And finally, if that is the case, what are the sturm-liouville's problems associated with sine fourier series and cosine fourier series? 

 A: Let $L$ be the operator $Lf=-f''$ defined on the domain $\mathcal{D}(L)$ consisting of twice absolutely continuous functions $f$ on $[-\pi,\pi]$ that satisfy periodic conditions $f(-\pi)=f(\pi)$ and $f'(-\pi)=f'(\pi)$. Then $L$ is symmetric on its domain because, for $f,g\in \mathcal{D}(L)$, one has
$$
    (Lf,g)-(f,Lg) = \int_{-\pi}^{\pi}f(t)\overline{g''(t)}-f''(t)\overline{g(t)}dt \\
   = \int_{-\pi}^{\pi}\frac{d}{dt}\{f(t)\overline{g'(t)}-f'(t)\overline{g(t)}\}dt \\
   = \left.\{f(t)\overline{g'(t)}-f'(t)\overline{g(t)}\}\right|_{t=-\pi}^{\pi}=0.
$$
Therefore, if $Lf=\lambda f$ and $f\ne 0$, it follows that $\lambda$ is real because
$$
           (\lambda-\overline{\lambda})(f,f)=(Lf,f)-(f,Lf) = 0.
$$
Likewise if $f,g$ are not identically $0$ and $Lf=\lambda f$, $Lg=\mu g$ with $\lambda\ne \mu$, then $(f,g)=0$ because
$$
         (\lambda-\mu)(f,g) = (Lf,g)-(f,Lg) = 0.
$$
Note that $L1 = \lambda 1$ where $\lambda=0$. This makes sense because the constant function $1$ is in the domain of $L$, as it is twice absolutely continuous, and it is periodic in the the function and its first derivative. And,
$$
          L\sin(nx) = n^2 \sin(nx),\;\; L\cos(nx)=n^2\cos(nx).
$$
So, $\lambda_n = n^2$ are eigenvalues for $n=0,1,2,\cdots$. The eigenspace $\{ 1\}$ for $\lambda=0$ is one-dimensional. The eigenspace $\{\sin(nx),\cos(nx)\}$ is two-dimensional with eigenvalue $\lambda_n=n^2$. There is latitude on how you choose the elements of $E_n$ for $n \ne 0$, but it is convenient to choose an orthogonal basis, which is what choosing $\sin(nx),\cos(nx)$ does. You could instead choose $\{ e^{inx},e^{-inx}\}$, which is also an orthogonal basis. Or you could choose $\{ e^{inx},\cos(nx) \}$, which is not an orthogonal basis for the two-dimensional eigenspace, even though it is a basis.
The standard Fourier basis is $\{ 1,\cos(x),\sin(x),\cos(2x),\sin(2x),\cdots\}$ which consists of orthogonal real functions. To expand $f \in L^2[-\pi,\pi]$ in such a basis,
$$
                  f \sim a_0 1 + a_1 \cos(x)+ b_1 \sin(x) + a_2 \cos(2x)+ b_2\sin(2x) + \cdots,
$$
one formally takes the dot product of $f$ with one of the basis elements as well as the series on the right. Using orthogonality,
$$
            (f,1) = a_0(1,1), \;\;\; a_0 = \frac{(f,1)}{(1,1)} \\
            (f,\cos(nx)) = a_n (\cos(nx),\cos(nx)),\;\;\; a_n = \frac{(f,\cos(nx))}{(\cos(nx),\cos(nx))} \\
            (f,\sin(nx)) = b_n (\sin(nx),\sin(nx)),\;\;\; b_n = \frac{(f,\sin(nx))}{(\sin(nx),\sin(nx))}.
$$
Using $(1,1)=2\pi$ and $(\cos(nx),\cos(nx))=\pi$, $(\sin(nx),\sin(nx))=\pi$ gives the Fourier series expansion:
$$
     f \sim \frac{1}{2\pi}(f,1) + \frac{1}{\pi}\sum_{n=1}^{\infty}\{(f,\cos(nx))\cos(nx)+(f,\sin(nx))\sin(nx)\} \\
    \sim \frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)dt
   + \sum_{n=1}^{\infty}\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\sin(nt)dt\sin(nx)+\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos(nt)dt\cos(nx).
$$
Note: The integral orthogonality did not come from such arguments. The "orthogonality" property of the trigonometric functions was an experimentally discovered fact when trying to write an initial condition for a vibrating string problem in terms of travelling waves. This predated Fourier's work, finite-dimensional linear algebra, eigenfunction analaysis, etc., by decades.
