Solution (source code)

= Solution

Write the <Fourier series> $f(x)=\sum_{n\in\mathbb Z}f_ne^{inx}$, with $f_n=(2\pi)^{-1}\int_{-\pi}^{\pi}f(x)e^{-inx}\,dx$. Smoothness makes its coefficients decay faster than every inverse power. Setting
$$
\boxed{u_f(x)=\sum_{n\in\mathbb Z}\frac{f_n}{1+n^2}e^{inx}}
$$
therefore gives a smooth periodic function, and termwise differentiation proves $-u_f''+u_f=f$. Conversely every solution must have these coefficients, proving uniqueness. Equivalently, a homogeneous solution has $\int(|u'|^2+|u|^2)=0$ by <integration by parts>, so vanishes.