Element of minimum norm in a closed subset of $L^2[-\pi,\pi]$ Let
$$Y=\Bigg\{ f\in L^2[-\pi,\pi]\, :\, \int_{-\pi}^\pi xf(x)\, dx=1,\,\, \int_{-\pi}^\pi (\sin x)f(x)\, dx=2 \Bigg\}.$$
My goal is to calculate the minimum norm element in $Y$.
The indication that appears to me is: to calculate $f\in Y$ of minimum norm, find a function of the type $g(x)=sx+t\sin x$ such that $f\in Y$ is fulfilled if and only if $f-g\in Z^\perp$ where $Z=\textrm{Span}[x,\sin x]$, that is, that $Y=g+Z^\perp$ is fulfilled. Then $f=g$.
But I don't understand why with this procedure I will get an $f$ element of minimum norm...
 A: I will just solve the problem, I think that at the end it will be clear what form the minimum must have. Define $f$ to be the minimum of $I(f):=\|f \|_{L^2[-\pi, \pi]}^2$ over $Y$, this is well defined since the ambient space $L^2[-\pi, \pi]$ is reflexive and $Y$ is closed in the strong topology of $L^2[-\pi, \pi]$ and convex. Indeed, $Y$ weak sequentially closed and $I$ weak sequentially lower semi-continuous and coercive would have been sufficient, but nevermind. Let $Z= \text{span}_{\mathbb{R}}\{x, \sin(x) \}$ and $g \in Z^{\perp}$, then in particular
$$\int_{-\pi}^{\pi} xg(x) \,dx = 0 \qquad\text{and} \qquad\int_{-\pi}^{\pi} \sin(x)g(x) \,dx = 0 \,.$$
Thus, for every $\varepsilon \in \mathbb{R}$ and $g \in Z$, we have $f+\varepsilon g \in Y$ since
$$ \int_{-\pi}^{\pi} x(f(x)+\varepsilon g(x)) \, dx = \int_{-\pi}^{\pi} xf(x) \,dx +\varepsilon \int_{-\pi}^{\pi} xg(x) \,dx =1 ,$$
and in the same way
$$ \int_{-\pi}^{\pi} \sin(x)(f(x)+\varepsilon g(x)) \, dx = \int_{-\pi}^{\pi} \sin(x)f(x) \,dx +\varepsilon \int_{-\pi}^{\pi} \sin(x)g(x) \,dx =2 .$$
Then the function
$$ J(\varepsilon) := \| f+\varepsilon g\|_{L^2[-\pi, \pi]}^2 = \int_{-\pi}^{\pi} (f(x)+\varepsilon g(x))^2 \, dx $$
has a minimum at $\varepsilon =0$, hence by the derivative test
$$ 0= \frac{\partial}{\partial \varepsilon} \Bigg|_{\varepsilon =0} J(\varepsilon) = 2\ \int_{-\pi}^{\pi} f(x)g(x) \, dx ,$$
and this holds for all $g \in Z^{\perp}$. Thus $f \in Z^{\perp \perp} = \overline{Z}=Z$ as $Z$ is closed. Hence $f=\alpha x + \beta \sin(x)$ for some $\alpha, \beta \in \mathbb{R}$, and imposing that $f \in Y$ you find $\alpha$ and $\beta$ from a system of two equations in two unknowns. In particular $f$ is necessarily a linear combination of $x$ and $\sin(x)$, which I think is what you were asking for.
A: $Z$ is closed, being finite dimensional so in any case have $f\in Z\cup Z^{\perp}$ so $f(x)=ax+b\sin x +g(x)$ for some real numbers $a,b$ and some $g\in Z^{\perp}.$ Now
$\tag1 \|f\|^2=\frac{2a^2\pi ^3}{3}+4\pi ab+\pi b^2+\|g\|^2.$
Let $\delta$ be the desired minimum. There is a sequence $(f_n)\subseteq Y$ such that $\|f_n\|\to \delta.$ $Y$ is closed convex so the parallelogram law shows that $(f_n)$ is Cauchy and so  converges to some $f\in Y\ $(because $Y$ is closed and $L^2$ is complete). $(1)$ implies that $g=0$ a.e.
By continuity of the inner product, $\langle x,f_n\rangle\to \langle x,f\rangle$ and $\langle \sin x,f_n\rangle\to \langle \sin x,f\rangle.$  It follows that $\langle x, ax+b\sin x \rangle=2$ and $\langle \sin x,ax+b\sin x\rangle=1.$ This gives the equations $\frac{a\pi^3}{3}+b\pi =1$ and $2a\pi+b\pi=1.$ It follows that $a=0$ and $b=\frac{1}{\pi}$ and so
$\tag 2 f(x)=\frac{1}{\pi}\sin x.$
