Minimizing a functional on $L^2$ 
Let 
  $$
 \mathcal{M} := \left\{f \in L^2([0,\pi]): \int_0^\pi f(x)\cos x dx =  \int_0^\pi f(x)\sin x dx = 1\right\}.
$$
Solve this problem: 
  $$ \tag{P}
\min_{\mathcal M} \int_0^\pi [f(x)]^2dx
$$

Using Cauchy-Schwarz, I get 
$$
1 = \langle f(x), \sin{x} \rangle \le \Vert f \Vert_2 \Vert \sin{x} \Vert_2 = \Vert f \Vert_2 \sqrt{\frac{\pi}{2}}
$$
i.e. 
$$
\Vert f \Vert_2^2 \ge \frac{2}{\pi}, \qquad \forall f \in \mathcal M.  
$$
Is this correct? Now what can I do to prove that this is the minimum? I would like to find a function $f \in \mathcal{M}$ which realizes that value, but I didn't manage to find it. Can you help me? 
Thanks. 
 A: If $g\in L^2([0,\pi])$ is orthogonal to $\sin(x)$ and $\cos(x)$ and $f$ is the minimum then for any $\epsilon\in \mathbb R$
$$
\langle f + \epsilon g, \sin(x) \rangle = \langle f, \sin(x)\rangle = 1\\
\langle f + \epsilon g, \cos(x) \rangle = \langle f, \cos(x)\rangle = 1
$$
So for each $\epsilon\in \mathbb R$, $f + \epsilon g$ belongs to $\mathcal M$ and $\phi(\epsilon):= \lVert f + \epsilon g \rVert ^2$ must have a minimum at $\epsilon = 0$. Since
$$
\left . \frac {d\phi} {d\epsilon} \right\vert_{\epsilon = 0} = 2\langle f, g\rangle = 0
$$
$f$ is orthogonal to $g$ and therefore (because of freedom in the choice of $g$) it is a linear combination of $\sin(x)$ and $\cos(x)$.
The condition $f\in \mathcal M$ allows us to determine the coefficients
$$
f = \frac 2 \pi (\sin(x) + \cos(x))
$$
A: You have actually proved that the infimum of the functional:
$$J[u]:= \int_0^\pi u^2(x)\ \text{d} x = \| u\|_2^2$$
is finite on the convex set $\mathcal{M}$, because you provided the lower bound:
$$ \inf_{u\in \mathcal{M}} J[u] \geq \frac{2}{\pi}\; .$$
On the other hand, the minimum of $J$ does exist, for $\mathcal{M}$ is closed and convex and $J$ measure the distance of the point $u\in \mathcal{M}$ from the zero function. Hence, now all you have to do is finding $f\in \mathcal{M}$ s.t. $J[f]=\min_{u\in \mathcal{M}} J[u]\geq \frac{2}{\pi}$.
But, you can notice that the system:
$$\phi_0(x)=\frac{1}{\sqrt{\pi}}\text{ and } \phi_n (x) = \sqrt{\frac{2}{\pi}}\ \cos (nx),\ \psi_n (x) = \sqrt{\frac{2}{\pi}}\ \sin (nx)\ \text{ for } n\in \mathbb{N}$$
is a complete orthonormal system in $L^2(0,\pi)$, hence any $u\in L^2(0,\pi)$ can be written as a Fourier series:
$$\tag{F} u(x) = \frac{a_0}{\sqrt{\pi}} + \sum_{n=1}^\infty a_n\ \phi_n(x) +b_n\ \psi_n(x)$$
with:
$$a_0:= \sqrt{\pi}\ \int_0^\pi u(x)\ \text{d} x,\ a_n:= \int_0^\pi u(x)\ \phi_n(x)\ \text{d} x,\ b_n:=\int_0^\pi u(x)\ \psi_n (x)\ \text{d} x\; .$$
Multiplying both sides of (F) by $\cos x$ and $\sin x$ and integrating term by term yields:
$$a_1 \sqrt{\frac{\pi}{2}}=\int_0^\pi u(x)\ \cos x\ \text{d} x,\ b_n\sqrt{\frac{\pi}{2}}=\int_0^\pi u(x)\ \sin x\ \text{d} x$$
hence $u\in \mathcal{M}$ iff:
$$a_1=\sqrt{\frac{2}{\pi}}=b_1$$
or equivalently iff:
$$u(x) = \frac{a_0}{\sqrt{\pi}} + \sqrt{\frac{2}{\pi}}\ \cos x+ \sqrt{\frac{2}{\pi}}\ \sin x+\sum_{n=2}^\infty a_n\ \phi_n(x) +b_n\ \psi_n(x)$$
with $a_0,a_2,b_2,\ldots ,a_n,b_n,\ldots \in \mathbb{R}$.
According to Parseval identity, you got:
$$J[u]=a_0^2+\frac{2}{\pi}+\frac{2}{\pi}+\sum_{n=2}^\infty a_n^2+b_n^2$$
and $a_0^2,a_2^2,b_2^2,a_3^2,b_3^2,\ldots,a_n^2,b_n^2,\ldots$ are $\geq 0$; thus $J[u]$ attains its minimum iff $a_0=a_2=b_2=\cdots=a_n=b_n=\cdots =0$, i.e. iff $u$ is the function:
$$f(x)=\frac{2}{\pi}\ (\cos x+\sin x)\; .$$
Therefore:
$$\min_{u\in \mathcal{M}} J[u]=J[f]=\frac{4}{\pi}$$
(observe that the actual minimum  of $J$ is strictly bigger then the rough lower bound you derived using Cauchy-Schwarz).
