# Prove this inequality from functional analysis

I want to prove this equality used in out lecture notes:

Let $D=(0,r)^2 \subset \mathbb{R}^2, r\geqslant 0$. Then, for any $u \in H^1(D)$, there holds

$$\lVert u\rVert \leqslant \frac 1 r \left|\int_D u(x)dx\right| + \sqrt{2}r \lVert\nabla u\rVert$$

where $\lVert\cdot\rVert$ is the $L^2$-norm on $D$.

I have no clue how to prove this estimate on $D$. Can somebody help me?

-

Let's rescale the variables: letting $v(x)=u(rx)$ for $x\in (0,1)^2$, we get $\|u\|=r\|v\|$, $\int u = r^2 \int v$, and $\|\nabla u\|=\|\nabla v\|$. Thus, the desired inequality is equivalent to $\|v\|\le \left|\int v\right|+\sqrt{2}\|v\|$.
To simplify notation, let $\bar v=\int v$. I claim that the following stronger inequality is true: $\|v-\bar v\|\le \|\nabla v\|$.
Proof: expand $v$ into Fourier series $$v(x_1,x_2)=\sum_{m,n\in\mathbb Z}c_{m,n}e^{2\pi imx_1}e^{2\pi i n x_2}.$$ Observe that $c_{0,0}=\bar v$. By Plancherel, $\|v-\bar v\|^2 = \sum_{m^2+n^2\ne 0} |c_{m,n}|^2$. Similarly, $\|\nabla u\|^2 = \sum_{m,n} (m^2+n^2)|c_{m,n}|^2$. Clearly, the second sum is not smaller than the first. $\quad\Box$