I am trying to bound $\int_{[0,1]^2} u^2$ in terms of its gradient and boundary integrals, $\int_{[0,1]^2} |\nabla u|^2$, $\int_{\partial[0,1]^2} u^2$, with the best possible constants.
So far I start out with the usual approach:
$$ |u(x,y)|=|u(x,0)+\int_{0}^y \partial_2 u(x,s)ds|\leq |u(x,0)|+\sqrt{y}\sqrt{\int_{0}^{y} |\partial_2 u(x,s)|^2ds}\\ \Rightarrow u(x,y)^2\leq 2u(x,0)^2+2y\int_{0}^{1}|\partial_2 u(x,s)|^2ds\\ \Rightarrow \int_{[0,1]^2} u^2\leq 2\int_{[0,1]}u(x,0)^2dx+2\int_{[0,1]}y\int_{[0,1]^2}|\partial_{2}u(x,s)|^2d(x,s)dy\\ \leq 2\int_{[0,1]}u(x,0)^2dx+\int_{[0,1]^2}|\partial_2 u|^2. $$
One way to improve this is to rescale the $y$ variable, which shows $$ \int_{[0,1]\times [0,1/2]} u^2 \leq 2\int_{[0,1]}u(x,0)^2dx+\frac{1}{4}\int_{[0,1]\times [0,1/2]}|\partial_2 u|^2, $$ and then split the integral over the square in two halves, which yields $$ \int_{[0,1]^2} u^2 \leq 2\int_{[0,1]\times\{0,1\}}u^2dx+\frac{1}{4}\int_{[0,1]^2}|\partial_{2} u|^2. $$ However, at this point I still have not used $\int_{\{0,1\}\times[0,1]}u^2$ and $\int_{[0,1]^2}\partial_1 u^2$.
Is there a trick to include these terms in the RHS and thereby obtaining better constants?