$\left(\int_E\sin x \,\mathrm{d}x\right)^2+\left(\int_E\cos x \,\mathrm{d}x\right)^2 \leqslant4\;?$ Is it true that $$\left(\int_E\sin x \,\mathrm{d}x\right)^2+\left(\int_E\cos x \,\mathrm{d}x\right)^2\leqslant4$$ for any measurable set $E \subseteq [0,2\pi]$? I'm trying to work out a functional analysis problem and finally it's equivalent to prove this.
 A: Define $\phi(x)=\mathbb{1}_E(x)$ for $0\leq x<2\pi$; extend $\phi$ to $\mathbb{R}$ as a $2\pi$-periodic function.
Let $z=\int_E e^{ix}\,dx$. The quantity of interest is $|z|$. Notice that  $|z|=e^{i\theta}z$ for some $\theta$ and so,
\begin{align}
0\leq |z|&=\int_Ee^{i(x+\theta)}\,dx=\int^{2\pi}_0\phi(x)e^{i(x+\theta)}\,dx\\
&=\int^{2\pi+\theta}_\theta \phi(x-\theta)e^{ix}\,dx=\int^{2\pi}_0\phi(x-\theta)e^{ix}\,dx
\end{align}
where the last identity follows from the $2\pi$-periodicity of $x\mapsto \phi(x-\theta)e^{ix}$ ( If $f$ is $T$ periodic and integrable, then $\int^T_0f(t)\,dt = \int^{T+a}_af(t)\,dt$ for all $a$).
Since $\phi$ takes only values in $\{0,1\}$, there is  a measurable set $E'\subset[0,2\pi)$ such that
$\phi(x-\theta)=\mathbb{1}_{E'}(x)$ for $x\in [0,2\pi)$. $E'$ is the translation (mod $2\pi$) of $E$ (wrap the interval $[0,2\pi)$ around the unit circle $|z|=1$ and $E'$ is obtained from $E$ by rotating the circle by and angle $\theta$).
All this shows that it suffices to assume that $E\subset[0,2\pi)$ is such that
$$\int_E e^{ix}\,dx=\int_E\cos x\,dx>0$$
Now find the measurable $E\subset[0,2\pi)$ that maximizes  $E\mapsto\int_E\cos x\,dx$ to conclude that $|z|\leq 2$.
A: First note that
$$
\int_0^{2\pi}1_E(x)\sin(x)\,dx=\int_0^\pi(1_E(x)-1_E(x+\pi))\sin(x)\,dx.
$$
On the interval $[0,\pi]$ the sine is non-negative and the difference has values in $\{-1,0,1\}$ so that
$$
\left|\int_E\sin x\,dx\right|\le\int_0^\pi\sin(x)\,dx=2.
$$
Note that this upper bound does not depend on $E$, just that $1_E$ has values in $\{0,1\}$.
Next observe that
$$
\left|\int_E\sin(x+c)\,dx\right|^2+\left|\int_E\cos(x+c)\,dx\right|^2
=\left|\int_E\sin(x)\,dx\right|^2+\left|\int_E\cos(x)\,dx\right|^2
$$
by trigonometric and binomial identities. As
$$
\int_E\cos(x+\pi)\,dx=-\int_E\cos(x)\,dx
$$
there is a value $c\in[0,\pi]$ with $$\int_E\cos(x+c)\,dx=0.$$ With the first observation the claim follows
$$
\left|\int_E\sin(x)\,dx\right|^2+\left|\int_E\cos(x)\,dx\right|^2
=\left|\int_E\sin(x+c)\,dx\right|^2\le 4.
$$
