I am trying to find a spectral solution for the for the boundary value problem of the ODE $$u^{\prime\prime}(x)-u(x)=f, \quad \quad u^{\prime}(0)=u^{\prime}(\pi)=0$$ for any $f: [o,\pi]\rightarrow \mathbb{R}$.
I tried tried to use the cosine series for $f$ and $u$, i.e. for $f$ we have, $$ f(x) = \frac{a_{0}^{f}}{2}+\sum_{n=1}^{\infty}a_{n}^{f}\cos(nx),$$ where $a_{n}^{f}$ is given by $$ a_{n}^{f}=\frac{2}{\pi}\int_{0}^{\pi}f(x)\cos(nx)dx$$
Afterwards I did some further calculations and ended up with $({1+n^{2}})a_{n}^{u}=-a_{n}^{f}$ for all $n \in \mathbb{N}_{0}$, or in other words $$\int_{0}^{\pi}\left(u(x)+ \frac{f(x)}{1+n^{2}}\right)\cos(nx)dx=0 \quad \forall n\in\mathbb{N}_{0}.$$
This is already enough to conclude that the only solution to this boundary value problem is $u\equiv f\equiv0$?
I tried to plug the Chebyshev polynomials for using $$T_{n}(\cos(\theta))=\cos(n\theta)$$ using substitution. But I did not get any further.