First encounter of Sturm-Liouville problem I have been assigned to find a solution to a specific Sturm-Liouville problem as preparation for an upcoming interview. This is in fact the first time I've ever met this class of problems (being a second year mathematics student at university). Anyway I've done some research and had a good crack at the problem but I find myself not knowing whether anything I've done is right.
Here is the phrasing of the question:

Any linear second order ordinary differential equation can be written in the classical Sturm-Liouville form,  
$$L(y(x))=\lambda w(x)y(x),\;x\in[a,b],\;(1)$$
in which the operator, $L$, is self-adjoint. Typically, $(1)$ will be subject to boundary conditions of the form,
$$A_1y(a) + B_1y′(a)=0,\;A_2y(b) + B_2y′(b)=0.\;(2)$$
The solution of $(1)$, subject to $(2)$, gives rise to an infinite set of eigenfunctions, $y_n(x)$, which are orthogonal with respect to one another and the weight function, $w(x)$. Each eigenfunction has an associated, real eigenvalue, $λ_n$.

The conditions we are given to work with are:  

$$L = \frac{d^2}{dx^2} + 1,\;x ∈ [0, 1],$$
  $$w(x) = 1,$$
  $and,$
  $$y(0) = 0,\,y'(1) = 0.$$

I am asked to find the analytic solution to this particular Sturm-Liouville problem which I worked out to be:
$$y_n(x) = B_n\sin\left(\left(2n+1\right)\frac{\pi}{2}x\right),\;n\in\mathbb Z$$
where $B_n$ is undetermined.
I am asked to determine $B_n$ by imposing:

$$\int_0^1y_n^2(x)\,dx=1.$$

Using this I found that $B_n=\pm\sqrt{2},$ which troubles me because in all the examples I've looked at regarding Sturm-Liouville problems a situation like this (where the constants are ambiguous) has not arisen. So I am worried I have made an error somewhere leading up to this. Anyway the next task is to represent $g(x)=x$ as an infinite series using the previously found eigenfunctions over the domain $x\in[0,1].$  
Now I searched online for a method to do this and found this document: Non-homogeneous Sturm-Liouville problems. Looking at the top of the second page they give a formula for finding the coefficients/weightings to express any function over $[0,1]$ as a series of eigenfunctions. Using this and my eigenfunctions I found that $$x=\frac{8}{\pi ^2}\sum_{n=1}^\infty\frac{(-1)^n}{(2n+1)^2}\sin\left(\left(2n+1\right)\frac{\pi}{2}x\right).$$
But I know this is completely wrong as I plotted this sum on MatLab to a sufficient number terms and it looked nothing like the function $g(x)=x$.
Now if you've read this far that is much appreciated and any help you could provide would be fantastic as I really would like to do well in solving this problem. Of course I will continue to research into this topic (I've even bought a textbook on Sturm-Liouville theory!) and will keep this post updated as necessary.
 A: Notes on your solution: 


*

*It might be worth noting that you can restrict $n$ to be a
non-negative integer, since any negative integer will reproduce a
solution you have already found.

*Typically the normalisation constant $B_n$ is chosen to be positive, since a negative one will just give negative values for coefficients later.  Essentially, the constant doesn't make much difference at all, so we pick a positive one for convenience's sake.

*From Sturm-Liouville theory we have that the eigenfunctions form a complete basis for the vector space of functions subject to the same boundary conditions, that is, any function $f$ with $f(0)=f'(1)=0$ can be written as a (probably) infinite linear combination of the eigenfunctions you've found. I'll try to explain what the coefficients should be instead of quoting a formula.


A Sturm-Liouville operator induces an inner product, essentially measuring the "angle" between two functions.  In this case $w(x)=1$ so I won't bother with the subscript $w$ that should really be there.  We define the inner product (think the generalisation of dot product) for this problem to be
$$\langle f,g\rangle = \int_0^1 f(x) g(x) dx$$
The useful parts about this are that the operator $L$ is self adjoint with respect to this inner product, namely that $\langle Lf,g\rangle = \langle f,Lg\rangle $, and that eigenfunctions with respect to different eigenvalues are orthogonal, that is if $Lf=\lambda_1 f$ and $Lg=\lambda_2 g$ with $\lambda_1 \ne \lambda_2$ then $\langle f, g \rangle = 0$.  (Both these facts are proved in the notes I gave you in the comments, but it might be useful to prove the first with your specific $L$ instead of the general case.
Now, we'd like to express $x$ in terms of the $y_n$ that you've found.  By completeness, $x = \sum_{n=0}^\infty c_n y_n$, for some undetermined $c_n$.  But look what happens if we take the inner product of both sides with $y_m$, for some $m$:
$$\begin{align}
x &= \sum_{n=0}^\infty c_n y_n \\
\langle x, y_m \rangle &= \sum_{n=0}^\infty c_n \langle y_n, y_m \rangle \\
\langle x, y_m \rangle &= c_m \langle y_m, y_m \rangle
\end{align}$$
I subtly used linearity of the inner product in there, which you should justify to yourself from the definition I gave above of the inner product.  Also, I used $\langle y_n, y_m \rangle = 0$ for $n \ne m$, which comes from orthogonality.  So almost all the terms of the sum have disappeared, save for the $\langle y_m, y_m \rangle$.  But you've already normalised the $y_m$ to set this equal to $1$! This means that we have a nice expression for $c_m$, which is $\langle x, y_m \rangle$.
Computing this integral on Wolfram Alpha because I'm lazy, we have $$c_n = \frac{4 \sqrt{2}}{(2n+1)^2 \pi^2}(-1)^n$$
$$x = \frac{8}{\pi^2}\sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)^2} \sin\left(\frac{2n+1}{2} \pi x\right)$$
So it looks like the only mistake you made was missing out $n=0$ in the sum, since this solution does converge nicely to $x$ on $[0, 1]$.  Even if the bulk of this post didn't directly solve your problem, I hope it's given you a useful insight into Sturm Liouville theory.
