Proof of an inequality for a function $f$ in the Hilbert space Prove that for any $ f \in H^1(0,\pi)$:
\begin{equation}
\int_0^\pi f^2 dx \leq \int_0^\pi \left(f'\right)^2 dx + \left(\int_0^\pi f dx\right)^2
\end{equation}
$H$ is the Hilbert space. 1 means that the 1st (weak) derivative exists.
I am thinking of applying some inequalities involving $L^2$ norms, such as Hoelder, but right now I can't think of a way to make it work.
A further hint would be greatly appreciated!

The given estimate is not the best. Indeed, we can show that
$$
\int_0^\pi |f|^2 dx \leq \frac{1}{4}\int_0^\pi |f'|^2 dx + \frac{1}{\pi}\left(\int_0^\pi f dx\right)^2.
$$This inequality can be rephrased as
$$
\int_0^\pi (f-\overline{f})^2 dx \leq\frac{1}{4} \int_0^\pi |f'|^2dx 
$$ where $\overline{f} =\frac{1}{\pi}\int_0^\pi f dx$. We can see this from
$$
\int_0^\pi (f-\overline{f})^2 dx = \int_0^\pi (f^2-2\overline{f}f +\overline{f}^2)dx = \int_0^\pi f^2 dx -2\pi \overline{f}^2 + \pi \overline{f}^2 = \int_0^\pi f^2 dx -\pi \overline{f}^2.
$$Without loss of generality, we may assume $\overline{f} = 0$, i.e. $\int_0^\pi fdx = 0$. Now, the result follows from the Fourier series of $f(x)=\sum_{k\neq 0} \widehat{f}(k) e^{i2kx}$ and Parseval's identity:
$$
\int_0^\pi |f|^2 dx = \pi\sum_{k\neq 0}|\widehat{f}(k)|^2\leq \frac{\pi}{4}\sum_{k\in\mathbb{Z}}|4k^2||\widehat{f}(k)|^2=\frac{1}{4}\int_0^\pi |f'|^2 dx. 
$$
