Consider the following question:
Consider the real Sturm-Liouville problem $$ \mathcal{L} y(x)=-\left(p(x) y^{\prime}\right)^{\prime}+q(x) y=\lambda r(x) y $$ with the boundary conditions $y(a)=y(b)=0$, where $p, q$ and $r$ are continuous and positive on $[a, b]$. Show that, with suitable choices of inner product and normalisation, the eigenfunctions $y_n(x), \quad n=1,2,3 \ldots$, form an orthonormal set. Hence show that the corresponding Green's function $G(x, \xi)$ satisfying $$ (\mathcal{L}-\mu r(x)) G(x, \xi)=\delta(x-\xi) $$ where $\mu$ is not an eigenvalue, is $$ G(x, \xi)=\sum_{n=1}^{\infty} \frac{y_n(x) y_n(\xi)}{\lambda_n-\mu}, $$ where $\lambda_n$ is the eigenvalue corresponding to $y_n$. Find the Green's function in the case where $$ \mathcal{L} y \equiv y^{\prime \prime}, $$ with boundary conditions $y(0)=y(\pi)=0$, and deduce, by suitable choice of $\mu$, that $$ \sum_{n=0}^{\infty} \frac{1}{(2 n+1)^2}=\frac{\pi^2}{8} $$
I showed that the desired Green's function is $$G(x,\xi)= \sum_{n=0}^{\infty} \frac{2}{\pi(-\mu -n)} \cos (n x) \cos (\xi n).$$ However, I am unsure as how to proceed. I tried setting up a problem with $$ (\mathcal{L} -\mu)y= f(x) $$ for $f$ being $x,\sin ,\cos$ and then trying to match the analytic solution with the one from Green's function, however, nothing worked. Could someone point me in the right direction?
I'll assume from the start that $r=1$.
You know that the Green's function for the linear operator $\mathscr L-\mu$ where $$(\mathscr L y)(x)=-\mathrm D(py')(x)+qy$$ Is $$G(x;\xi\mid \mu)=\sum_{n=1}^\infty\frac{y_n(x)y_n(\xi)}{\lambda_n-\mu}$$ I.e, it is the unique solution of the equation $$(\mathscr Ly)(x)-\mu y(x)=\delta(x-\xi)$$ With homgeneous Dirichlet BCs.
Here $\{(y_n,\lambda_n)\}_{n\in\mathbb N}$ are the nontrivial orthonormal eigenfunctions and eigenvalues of the operator $\mathscr L$, that is they satisfy $$\mathscr Ly_n=\lambda_ny_n \\ \langle y_m,y_n\rangle=\int_a^by_m(x)y_n(x)\mathrm dx=\delta_{m,n}$$
In the case of $p=1$ and $q=0$, and BCs $y(0)=y(\pi)=0$ you know that the eigenfunctions and eigenvalues are (The scaling is important here!) $$\lambda_n=n^2 \\ y_n(x)=\sqrt{\frac{2}{\pi}}\sin(nx)$$ Hence, your Green's function is $$G(x;\xi\mid \mu)=\frac{2}{\pi}\sum_{n=1}^\infty \frac{\sin(nx)\sin(n\xi)}{n^2-\mu}$$
So, we could write $$\sum_{n=1}^\infty\frac{\sin(n\pi/2)\sin(n\pi/2)}{n^2}=\sum_{n~\text{odd}}\frac{1}{n^2}=\frac{\pi}{2}G(\pi/2;\pi/2\mid 0)$$
However, we also know (link1,link2) that, given functions $u,v$ that nontrivially satisfy the equation $\mathscr L y=0$ with $u(a)=0~,~v(b)=0$ that our Green's function (with $\mu=0$) may be expressed as
$$G(x;\xi)=\begin{cases}\frac{u(x)v(\xi)}{p(\xi)W(\xi)} & x<\xi \\ \frac{v(x)u(\xi)}{p(\xi)W(\xi)} & x>\xi\end{cases}$$
Where $W=uv'-vu'$.
Again in our case taking $p=1,q=0$ we can see that our fundamental solutions are $$u(x)=x~~,~~v(x)=\pi-x$$
Hence $$G(x;\xi\mid 0)=\frac{1}{\pi}\begin{cases}x(\pi-\xi) & x<\xi \\ \xi(x-\pi) & x>\xi\end{cases}$$
Therefore $$\frac{\pi}{2}G(\pi/2;\pi/2\mid 0) =\frac{\pi}{2}~\frac{1}{\pi}~\frac{\pi}{2}\left(\pi-\frac{\pi}{2}\right)=\pi^2/8$$
Hence $$\sum_{n~\text{odd}}\frac{1}{n^2}=\frac{\pi^2}{8}$$ Done.
Additionally, this also allows you to work out
$$\sum_{n\in\mathbb N}\frac{1}{n^2}=\sum_{n~\text{even}}\frac{1}{n^2}+\sum_{n~\text{odd}}\frac{1}{n^2} \\ \sum_{n=1}^\infty\frac{1}{n^2}=\sum_{k=1}^\infty \frac{1}{(2k)^2}+\sum_{n~\text{odd}}\frac{1}{n^2} \\ \implies \left(1-\frac{1}{4}\right)\sum_{n=1}^\infty \frac{1}{n^2}=\sum_{n~\text{odd}}\frac{1}{n^2}=\pi^2/8 \\ \implies \sum_{n=1}^\infty\frac{1}{n^2}=\pi^2/6.$$